Results 1 to 16 of 16
Thread: multiple gui
- 06-01-2011, 04:08 PM #1
Member
- Join Date
- Jun 2011
- Location
- Tsukuba, Japan
- Posts
- 63
- Rep Power
- 0
multiple gui
Hi all,
I know this may have been asked a zillion times, but I couldn't find any direct replies in my search.
My question is, suppose i use a main GUI(GUI1) button to open another GUI, say GUI2, how do I close GUI2 without closing GUI1?
Restated, I only want one GUI window to close, the remaining to stay open. That includes if i want to close GUI3 and not GUI2, even if i used GUI2 to call GUI3.
Closing GUI1 should be definitive, ofcourse.
Please help.
Thanks.
- 06-01-2011, 04:13 PM #2
Have you tried using the setVisible method?
- 06-01-2011, 04:20 PM #3
Member
- Join Date
- Jun 2011
- Location
- Tsukuba, Japan
- Posts
- 63
- Rep Power
- 0
i think i found a cross post. i'll close this thread and come back later if necessary.
i haven't. i will though, thanks.
- 06-01-2011, 04:23 PM #4
Member
- Join Date
- Jun 2011
- Location
- Tsukuba, Japan
- Posts
- 63
- Rep Power
- 0
actually, help me out, if i use the close button, how do i call setVisible? what is the mouse event code?
- 06-01-2011, 04:26 PM #5
Have you looked up that method in the API documentation? That should explain how to use it.how do i call setVisible?
How is this related to closing a window?what is the mouse event code?
- 06-01-2011, 04:31 PM #6
Member
- Join Date
- Jun 2011
- Location
- Tsukuba, Japan
- Posts
- 63
- Rep Power
- 0
i don't know. the code in the constructor for the main class is exit_on_close. its generated by a click on the x box on the JFrame. so i figured i might need an event trigger for the set Visible.what is the mouse event code?
i have a lot to learn!! :)
- 06-01-2011, 04:35 PM #7
Member
- Join Date
- Jun 2011
- Location
- Tsukuba, Japan
- Posts
- 63
- Rep Power
- 0
this is the code i use now. "setDefaultCloseOperation(EXIT_ON_CLOSE);"
what do i change it with?
- 06-01-2011, 04:39 PM #8
Time to read the API doc for the method you are using to see what options it has.
- 06-01-2011, 04:41 PM #9
Member
- Join Date
- Jun 2011
- Location
- Tsukuba, Japan
- Posts
- 63
- Rep Power
- 0
got it. thanks for not giving me the easy way out. :D
also could you suggest a method for converting a regular rectangular grid of (i,j) to a hex grid of (i,j)?
- 06-01-2011, 04:44 PM #10
Please define in java code a regular grid and a hex grid. I have no idea what you mean by those terms.method for converting a regular rectangular grid of (i,j) to a hex grid of (i,j)
- 06-01-2011, 04:47 PM #11
Member
- Join Date
- Jun 2011
- Location
- Tsukuba, Japan
- Posts
- 63
- Rep Power
- 0
this is the code i have use.
public void paintComponent( Graphics g ){ // main rendering recipe
Graphics2D g3 = (Graphics2D)g;
g3.setColor( Color.black );
g3.fillRect( 0, 0, getWidth()-1, getHeight()-1 );
int w = 810 / (810/30);
int h = 630 / (630/30);
for(int col=0;col<(810/30);col++){
for(int row=0;row<(630/30);row++){
for(int k=0; k<works1.l; k++){
if( jiffy.rulbas[col][row] == k){
g3.setColor(jiffy.colors[k]);
repaint();
} g3.fillRect( col * w +1, row * h +1, w-2, h-2 );
} }}
it creates a rectangular grid on a display window.
i need to create a hexgrid. and i am having difficulty visualising the pixels, and also drawing the hexagon itself.
- 06-01-2011, 05:01 PM #12
What is a hex grid? Do you have an algorithm or design for drawing one? Not really part of java coding.
To compile and execute this code, you need a definition for jiffy
- 06-01-2011, 05:15 PM #13
Member
- Join Date
- Jun 2011
- Location
- Tsukuba, Japan
- Posts
- 63
- Rep Power
- 0
the code is executing. a hex grid, is one like in this picture: Google Image Result for http://www.thealmightyguru.com/Humor/Inventions/Images/Grid-Hex.gif
i do have an algorithm, but it might take time to dig it up. i will post it tomorrow, its past 12 here in japan.
thanks for your help.
- 06-01-2011, 06:15 PM #14
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
gamedev.net used to have some articles on drawing hex maps, and using masks to figure out which hex a user has clicked on.
I would suggest using an image file for the hexes. It's a lot easier.
- 06-02-2011, 02:46 AM #15
Member
- Join Date
- May 2011
- Posts
- 8
- Rep Power
- 0
I just had a post like this; I wanted to have a JFrame (in swing) and multiple JPanels. Just remove the current JPanel when a button is clicked and add another one.
- 06-02-2011, 04:26 AM #16
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
Similar Threads
-
Multiple iframes
By Pablo3728 in forum Java ServletReplies: 5Last Post: 09-21-2010, 02:30 AM -
Running multiple threads on multiple CPU cores?
By Dosta in forum Threads and SynchronizationReplies: 2Last Post: 09-19-2010, 03:48 PM -
Multiple SwingWorkers
By Arne in forum Threads and SynchronizationReplies: 12Last Post: 08-26-2010, 02:54 AM -
Multiple Users
By peiceonly in forum Threads and SynchronizationReplies: 5Last Post: 06-09-2008, 09:17 AM -
Multiple Inheritance
By mew in forum New To JavaReplies: 1Last Post: 12-01-2007, 10:04 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks