• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple frames from a parent frame

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JFrame frame = new JFrame();

You might want to be a little more specific with your question if you want a more specific answer.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
^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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> the way I want to do my GUI is to have a menu that will display the
> different panels the user chooses

CardLayout is perfect for this scenario.
 
Scott Carlson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Scott
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you should get most of your info here

http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html


here's a simple demo

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have try this demo and he dont work as on tutorial.
reply
    Bookmark Topic Watch Topic
  • New Topic