File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFrame vs JOptionPane

 
Alan Smith
Ranch Hand
Posts: 185
Firefox Browser Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am building an application that has a main gui built with a jframe and has buttons such as load, save (text from text areas), etc. When I use these buttons i create a new jframe as a pop up menu for each button. Now I have just discovered JOptionpane. Is there any reason to use JOptionPane over the JFrames for this kind of scenario? Are JFrames heavy on memory in comparison, etc? If anyone knows the advantages/disadvantages could you let me know because I am going to stick with JFrame windows for all my 'pop up' menus.

Cheers
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With JOptionPane (and other modal JDialogs), the dialog will block access to the parent JFrame until the dialog is closed. JFrames never block access.
 
Alan Smith
Ranch Hand
Posts: 185
Firefox Browser Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:With JOptionPane (and other modal JDialogs), the dialog will block access to the parent JFrame until the dialog is closed. JFrames never block access.


But can I still manipulate components on the main frame using the optionpane ie. Could I use a button on the option pane that will save the text from a textarea on the main gui.

Thanks
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but you will have a very peculiar interface. Why don’t you put the buttons on the frame?
 
Alan Smith
Ranch Hand
Posts: 185
Firefox Browser Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Yes, but you will have a very peculiar interface. Why don’t you put the buttons on the frame?


yes I know that but I was just making sure. I have a lot of different options like load, save, etc so I think its best to have pop up windows to hold all the relevant options for each button ie, confirm choice, etc.
 
Darryl Burke
Bartender
Posts: 5116
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a job for a menu and/or toolbar.
 
Randall Twede
Ranch Hand
Posts: 4353
2
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first: what rob said, JOptionPane dialogs are modal
and IMO they are mainly a convenience when you need a simple modal dialog. most of the time that is all you need.
i also think Darryl might be right. if you have a great many buttons, some might be better as menu items. it will make the GUI less cluttered. especially actions like save and load are generally menu choices.furthermore, saving and opening files is usually handled by a JFileChooser which displays its own dialog.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic