Hi, I want to open multiple frames from a parent frame. I am creating an application. In that I've one main frame along with menus. Using those menus I'm calling another frames in that frame. How to call other frames in the main parent frame ? Any suggestion / code ... [ July 27, 2005: Message edited by: Sumit Mhatre ]
How did you open your parent frame? Opening a second frame is no different really. In your event handler for whatever menu item, create a new instance of whatever frame you want and make it visible.
Matthew Taylor
Rancher
Joined: Jun 13, 2004
Posts: 110
posted
0
If you're going to have one main frame of the application and the menu selections are just going to change what is going to be displayed in the frame, I suggest you only create one frame. Then you create custom panel classes to be displayed within that frame. When a menu item is chosen, call a method within the frame to reload with a different panel specified by the menu selection. If you create all the panels upon frame construction, you should be able to save their states even when they aren't being displayed.
Another simpler option might be to use a JTabbedPane and forget about using the menu to navigate the application.
Grails Consultant
http://dangertree.net
Scott Carlson
Greenhorn
Joined: Oct 04, 2005
Posts: 4
posted
0
^bump^
This is exactly what I am looking to do. I am new to Java but I am in a tight bind in learning how to do a GUI from Java by next week. I have been working with JBuilder and the way I want to do my GUI is to have a menu that will display the different panels the user chooses.
Does anyone have an example of this that I could see?
Any advice or tutorials someone might have that talks about calling multiple panels in a single Frame or Window would be great.
Thanks in advance,
Scott
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> the way I want to do my GUI is to have a menu that will display the > different panels the user chooses
I should of been more specific sorry. I want the user to open up new windows or panels when he or she selects a certain menubar option.
Scott
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
if you want multiple windows (frames) showing, reply #1 in this thread is the start of what you have to do.
if you only want the one window (frame) showing, but the panel displayed is dependent on user (menu) selection, CardLayout is your best option.
Scott Carlson
Greenhorn
Joined: Oct 04, 2005
Posts: 4
posted
0
Thanks for the info. I will try and find something on how cardlayout works. If anyone can point me to a good tutorial on this or some advice as to how to set this up that would be great. Otherwise, thanks again.