21

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).

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
Jules Olléon
  • 6,733
  • 6
  • 37
  • 47
  • http://stackoverflow.com/questions/2248342/skinning-java-applications/2248437#2248437 – Jonas Apr 11 '10 at 12:58
  • @Jules Olléon: +1 Note that in some case where I needed some non-existing component (like, say, a "dual/tri/quad progress bar" [different colors in the same "progress bar"]) and wanted it to look *exactly* the same on Linux, Windows and OS X I took the pain to write my own, ligthweight, self-made, pixels-based component. It's not dissimilar to writing 2D GUI for games (menus etc.). Oh btw, all the suggestions talking about changing the default layout are unlikely to give acceptable results on OS X: you want to make sure to *only* apply use these L&F when you're not on OS X ;) – SyntaxT3rr0r Apr 11 '10 at 16:15
  • @Jules Olléon: also note the second reason why you may no want to use these L&F on OS X is that doing so would likely break the Apple guidelines (by default, without messing with anything, the Java JButton *does* look very nice on OS X). – SyntaxT3rr0r Apr 11 '10 at 16:16

10 Answers10

18

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.

matt
  • 333
  • 2
  • 10
  • 23
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
5

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
  • 131,802
  • 30
  • 241
  • 343
5

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
  • 7,933
  • 17
  • 56
  • 72
  • 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 Apr 11 '10 at 12:36
  • 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 Apr 11 '10 at 13:09
  • 1
    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 Apr 12 '10 at 10:27
4
try
{
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e)
{}
Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287
2

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
  • 55,802
  • 13
  • 100
  • 117
1

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
  • 3,570
  • 22
  • 19
1

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

stacker
  • 68,052
  • 28
  • 140
  • 210
1

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
  • 73,784
  • 33
  • 194
  • 347
0

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
  • 1,935
  • 28
  • 32
-2

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
  • 6,726
  • 4
  • 30
  • 44