tags:

views:

157

answers:

5

Hi StackOverFlow Family

I've develop a Java Swing application but I want to improve the design of my Swing frames. I search for this issue in google, but i cant find an adequate solution. Please share your experiences and opinions regarding this issue.

p.s. Maybe this question is not good for you but it is important for me and other like me

+1  A: 

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.

Abboq
A: 

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:

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.

Ninefingers
Rather than GridBagLayout - I'd use MigLayout. http://www.miglayout.com/ It works in both SWT and Swing.
Nate
+8  A: 
OscarRyz
A: 

Check out this question discussing how to design a GUI in Swing.

Adamski
A: 

Also take a look at JSR-296: which is an attempt to formalize some of the aspects of putting together an application, like how to handle resource-bundles , how to fire of 'tasks' (background and modal etc).

The current (and some previous versions) of Netbeans has a Wizard to build JSR-296 apps. ("Desktop Applications").

http://jcp.org/en/jsr/detail?id=296

monojohnny