• 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

Structure of Multi-frame Swing App

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apologies if this is a very basic question. I am new to Swing and am having a some difficulty. I am trying to write a little application which is basically one Frame with a menu bar. When a user clicks on a menu option, I need to open another frame and get them to change some stuff. I dont know how exactly to do this. I need a modal window (where the main frame is the parent) with some custom buttons on (i.e. not just OK / Cancel). My questions is what method should I use to do this. A Dialog box does not seem correct here. Also, I have thought about JInternal Frame but I dont think this is appropriate either. How can I just create a frame that is a child of another frame. This leads me to another question of flow control. What if I wanted more than 1 window in my application? How do I flow from frame to frame. Really what I just need is a tutorial detailing a bigger swing application than what is typically available. I usually do web development so this is a bit of a mind-set problem for me I think.
 
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Everything you need can be found here.

Whenever you ask yourself : How to do .... This is THE page. I recommend you download the entire tutorial for studying off line.

At this page, look for "How to Make Dialogs".

The Java API Docs are very poor in terms of examples, so the tutorial above is a good companion during your development time.
[ September 21, 2006: Message edited by: Edisandro Bessa ]
 
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
A JDialog is indeed appropriate per your requirements which were When a user clicks on a menu option, I need to open another frame and get them to change some stuff. I dont know how exactly to do this. I need a modal window (where the main frame is the parent) with some custom buttons on (i.e. not just OK / Cancel).

What you will want to do is create a class that extends JDialog. You then have a modal frame ( if you setModal(true) ) and can layout components on it just like any other container.

As far as flow, there are many ways to achieve this. A better way than Frame to Frame to Frame is JPanel to JPanel to JPanel where you can just replace a JPanel on a JFrame instead of the JFrame itself which is a tad heavier of an operation, or even using a JTabbedPane to achieve a wizard type of flow.

It will be beneficial for you to go through the tutorial linked by Edisandrom or at least glance at the parts you need. And as always, when you get stuck with something, ask us. We'll see if we can help.
 
Deirdre McHugh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all, I figured it out after going through the tutorial (which I had read before but I am a bit of a skimmer). Gregg, I will take on your suggestion about the JPanels (this app is getting bigger every day). Thanks again.
reply
    Bookmark Topic Watch Topic
  • New Topic