How to make good gui design in Swing
Go and buy this book:
(source: filthyrichclients.org)
From the description page:
Filthy rich clients are applications that are so graphically rich that they ooze cool. They suck the user in from the outset and hang onto them with a death grip of excitement. They make the user tell their friends about the applications.
In short, they make the user actually enjoy their application experience. When was the last time you enjoyed using a software application?
Maybe you need more Filthy Rich Clients in your life.
Read it and understand it until get a UI you like.
:)
Joel Spolsky has a great article: User Interface Design for Programmers. It doesn't address Swing specifically, but it explains how to design simple, efficient UIs for a non-programmer audience.
Well, I'll give you my experience. I prefer SWT & Eclipse in general, simply because it integrates much more nicely and is so flexible with extension points and whatnot, but I appreciate sometimes that's overkill.
When using swing, I nearly always use GridBagLayout unless the form is very simple. This is because most GUIs I design or experience contain lots of elements that aren't necessarily laid out in a flow or table-style - gridbaglayout offers the ability to draw the ui in a way java likes + allow resize if necessary, or you can prevent this from happening.
Specific things I make use of:
GridBagConsts.insets = new Insets(2,2,2,2);
This adds padding to any cell in the gridbaglayout, making it look more like a program designed for Gtk/by MS than something I threw together.
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e)
{
System.out.println("Error setting native LAF: " + e);
}
Setting the look and feel to that of the system - I'm not a fan of whatever the builtin theme (metal) is and integrating with the system is much more friendly.
That's about it for hard and fast rules. Things I suggest you look at:
- Tutorial in Swing: http://java.sun.com/docs/books/tutorial/uiswing/
- GridBagLayout tutorial: http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html
- Again: http://academicjava.com/Java_help/Tutorial_Examples_Swing_28.html
Other than that, it is very much application-specific and you'll need to read up on general UI design. In general, it helps to use built in controls and tools i.e. those that look like the system. The Java Class Library, for example, includes File Choosers: http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html which when set to the system LAF appear like Windows or Gnome(-ish) choosers. Taking steps to look familiar with every other application will, in turn, make your application easier to use.