views:

560

answers:

10

So far I've only built "small" graphical applications, using swing and JComponents as I learned at school. Yet I can't bear ugly JButtons anymore. I've tried to play with the different JButton methods, like changing colors, putting icons etc. but I'm still not satisfied. How do you make a nicer GUI in java ?

I'm looking for not-too-heavy alternatives (like, without big frameworks or too complicated libraries).

+1  A: 

You may want to try JavaFX. For all its problems, I find that if you want to put a decent (preetier than Swing) interface over your Java application, its quite easy to do. Plus good Java integration. You can implement Java interfaces in JavaFX and vice versa.

Chuk Lee
A: 

This article shows how to extend JButton and overide the methods for painting the component.

stacker
+3  A: 

Have you at least tried with nimbus look'n'feel? that is a little bit better than the others..

UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");

only downside is that it requires at least Java6 update 10.

Jack
That's indeed a cool look and feel, thanks !
Jules Olléon
+2  A: 

I am using SWT. Try it , it is really very nice java gui framework, eclipse is build around it. You can use also this plugin for eclipse to create your forms Instantiations.

Roman
SWT does behave a bit different depending on OS. On Mac OS X some keyboard shortcuts for navigating lists don't seem to work and on Linux I had some problems with the backing (C) library dependencies. It's just more OS dependend than Swing, so an app using it needs more testing.
extraneon
The main objection to this answer for *this* question is that it involves a change of toolkit, which is too heavyweight for the questioner. Otherwise a good idea.
Donal Fellows
You are right this is the main problem with it is is OS dependent. But in case you are a looking for a great looking and really fast GUI in java, I would choose SWT. The best Universities start the GUI education by pushing SWT.
Roman
+9  A: 

Swing supports changing the Look & feel.

This tutorial explains how:

UIManager.setLookAndFeel(lookAndFeelClassName);

Another way is to start your app with the L&F:

java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel MyApp

Here is a list of 10 very nice look and feels.

Bozho
Thanks, that's a really easy way to give a fresh look to my GUIs !
Jules Olléon
+1 for the list, I will pimp few old swing apps, thanks
stacker
+1  A: 

Our project manager doesn't like JButtons as well and we're using JIDE OSS buttons instead(and lot's of other JIDE components). SwingX also offers an alternative - JXButton. IMO these are the two most valuable external Swing libraries around.

Bozhidar Batsov
A: 

The easiest is to stay with Swing and use a different look and feel.

What CAN be done easily is shown at http://www.jgoodies.com/freeware/metamorphosis/index.html (Use this this web start linkto see it in action)

Either bundle a L&F with your program, or choose one of the built in. I like Nimbus but it must be explicitly selected in your code.

Thorbjørn Ravn Andersen
+1  A: 
try
{
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e)
{}
Martijn Courteaux
A: 

If you are a little bit into graphics design, you might want to consider creating your own design with Synth, which is part of the standard JRE. If you don't want to create your own, google for free existing themes which you may use.

Alternatives to Synth are either Synthetica (free for personal, non commercial use) or Substance ("free" as in "BSD License").

Tedil
A: 

It would be nice if Java had a similar tool to Interface Builder (the GUI development tool that comes with Xcode) - by far the best UI builder I've ever seen.

djhworld