This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
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.