Question: JFrame or JDialog for new application window(s) and frame(s)?
945083Aug 16 2012 — edited Oct 23 2012Hi All - I realise this may be a really dumb/stupid question but I haven't really found an answer anywhere yet. I'm new to Java but have developed apps in .NET for a few years now and am looking for some advice and direction on basic Swing application layout/design planning
In my .NET application I had a main form for the main application, when the user selected menu options or clicked a button (or right click etc) I would simply call a new form item. In .NET a form is a form, it just holds buttons/controls etc and has its own methods and subs and does not differentiate between form objects. I design these separately and code them individually as each form would perform different tasks, then from my main form I call them whenever they are required - all controls are accessible from any part of the code
After doing some reading and searching I (think) that Java Swing basically encourages the use of only 1 main JFrame and then if you need another form to enter data on or store separate related controls then I believe that you need (or are encouraged to use) a JDialog to do this? Is there an issue if I have say 5 or 6 JFrames called from the main window or is it better to use the JDialog?
I have added both another JFrame and also a JDialog to my work in progress and I can call both by using the standard .setVisible call from the main app, so my question relates to which is the best practice in Swing? What are the advantages/disadvantages of using one or the other approach?
Different forums seem to have conflicting opinions, a few articles mention you should only use 1 main JFrame and then use panes etc inside that and make them visible when needed; however my app really needs separate windows so the user can work on several tasks at one time. For instance my app manages telecomms equipment and related services, so there is a need to manage the equipment in one window and then possibly view KPI data in a graph in another window, and make a new XML data file in another (and countless other tasks blah blah)
From what I've read I believe a JDialog will do pretty much what I want as it extends JFrame in a lot of ways, but I would like some advice from people that work with Swing in the real world to give me their opinions on the best approach
Apologies for the newbie stupid question but I would rather start with a good approach than just hack a load of bits together that just about do the job!......which I have to confess has been my main approach to programming so far :)