Results 1 to 4 of 4
- 01-10-2010, 04:17 PM #1
Member
- Join Date
- Jan 2010
- Posts
- 2
- Rep Power
- 0
-
Hello and welcome to the forum!
There are several options you can do here, including simply setting the current JFrame's visible property to false and the other JFrame's property to true via the JFrame#setVisible(boolean visible) method.
But there are other and perhaps more important issues involved here, issues that if you address could help us give you more than just general answers. From a tactical point of view, there are scope issues -- are both JFrame variables visible from within the button's action listener and if not, how to make them visible. Your program structure and code would tell us more about how to deal with this.
And perhaps more importantly still are the strategic issues -- just what you are trying to do in an overall general sense, not in a Java or Swing sense? The reason this is so important is that often swapping JFrames is precisely not what you really what you want to do here. If you think of the programs you know and use, word processors and such, it is uncommon where you'll see swapping GUI windows. More often you'll see a main GUI window with occational dialogs, sometimes you'll have different GUI panels held in tabbed panes, and sometimes you'll see GUI panels or views swapped within a main application (within a single stable JFrame).
So in that mode, what is your goal here? Are you trying to do a log-on dialog that when completed opens the main GUI? Are you instead trying to get input from the user to allow them to change a property of your program? Our recommendations will likely depend on this.
Much luck and hope we can help! Oh, and again, welcome!Last edited by Fubarable; 01-10-2010 at 05:35 PM.
- 01-10-2010, 05:46 PM #3
Member
- Join Date
- Jan 2010
- Posts
- 2
- Rep Power
- 0
Thank you:=)
Actually ,I will desgin a hospital automation system.The first frame which I've desgined is "Introduction Menu".This Frame includes a button which open "Doctor Menu" ..
The code I've writtn ,for the first frame is:
JFrame frame0=new JFrame();
frame0.setVisible(false);
this.setVisible(false);
And I've written for the second frame ( under the main function)
JFrame frame2=new JFrame();
frame2.setVisible(true);
When I compiiled, first frame closed but second frame was nor opening as I ve designed.An empty frame was coming.
??
-
1) Consider using a CardLayout to swap JPanels rather than JFrames.
2) If you really need to use swapping JFrames, then you'll have to give us more information for us to be able to figure out what's wrong. For one, we'll need to see more code, but please don't forget to use code tags when you post your code (please see my signature below).
Much luck.
Similar Threads
-
navigation b/w frames
By imrankhan in forum AWT / SwingReplies: 3Last Post: 03-19-2012, 12:25 PM -
SWT Transition Widget - STW
By fossilman2005 in forum SWT / JFaceReplies: 0Last Post: 01-02-2010, 11:16 PM -
Switching Frames
By jonnytabpni in forum New To JavaReplies: 1Last Post: 11-08-2009, 10:12 PM -
C++ to Java transition
By Mareq in forum New To JavaReplies: 2Last Post: 08-10-2009, 06:31 AM -
Help regarding Frames
By ramesh.8189 in forum AWT / SwingReplies: 14Last Post: 02-15-2009, 08:12 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks