7

I am working on an application that uses Swing. I have successfully created a main GUI for the user to work from. However, I would like to allow the user to change his/her settings. How should I go about creating the settings window? Would using a new JFrame called 'Settings' be the best way to handle this, or is there something better to use than a second JFrame?

(Note: The settings JFrame, on exit, will not close the main GUI, it will use the DISPOSE method)

I would like to handle this in a way that consumes the least amount of memory, but maintaining a professionalized look to the application.

Anthony
  • 496
  • 3
  • 9

2 Answers2

5

Have you considered a CardLayout? http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html

Personally, I find the use of a separate dialogue to be a bit dated for configuration settings. I prefer tabbed layouts, which are card layouts decorated with a tab bar across the top.

You could easily wrap your application in a near-top-level card layout and add a menu action to switch to the configuration card, with the "acknowledgement" or "cancel" buttons switching back to the main application card.

In the end, it is really about what your users prefer, but remember a lot of them might prefer what they know, even if it is not a better solution. You have to find a balance, and if your implementation rocks, then eventually they will want your approach to the problem to be used in other applications.

A perfect example of this is tabbed browsing, as opposed to multiple windows. Personally, I can't imagine going back to multiple-window browsing now that I have become accustomed to browsing tabs, but at one point in time, multiple windows was the only game in town.

In the end, if you find out you made the wrong choice, keep you code clean enough to easily implement with either solution. As long as your configuration screen is just a plain JPanel (or wrapped in just a JPanel), it shouldn't be very hard to do.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
  • 1
    I don't agree that `CardLayout` is the best choice for this, I personally prefer to see options settings in a modal `JDialog` or `JOptionPane`. OTOH the rest of your answer addresses that type of thing 'people are different/things change over time'. Great observations & explanation. – Andrew Thompson Apr 11 '12 at 19:33
  • I like the basic idea of the CardLayout. Seems very clean and neat. I see that most programs have a modal JDialog, in regards to a settings window. I'll try using both and see which way looks cleaner. – Anthony Apr 11 '12 at 19:44
0

you have to look at the ApplicationListener interface, especially at the 'handlePreferences' method of that interface.

11684
  • 7,356
  • 12
  • 48
  • 71