Look And Feel.
Swing has programmable look and feel. It can be made to look like Motif, Mac etc.
Mac L&F
The Mac LAF is disabled except for Mac platforms. This is restriction is fairly easy to defang so that you can
test your multi-platform code, without buying Mac. Just change this method:
public boolean isSupportedLookAndFeel()
{
return isNativeLookAndFeel();
}
to
public boolean isSupportedLookAndFeel()
{
return true;
}
However, if you released code that did that, the Apple lawyers would be down your neck. Even if you used the
third party QuaQua L&F that more closely
mimics the Mac OS X UI than Sun’s L&F does, you would get in legal trouble if your app allowed QuaQua
to run on anything but a Mac, except for development testing. If you use QuaQua, you must bundle the quaqua.jar with your application/Applet and ensure it is on the classpath.
Selecting L&F Programmatically
Note there are two techniques of setting a L&F. You can either do pass a new
LookAndFeel object or the name of the LookAndFeel class as
a String. The advantage of the first approach is the compiler will check that the
L&F actually exists at compile time, preventing you from making a typo. The advantage of the second approach
is you don’t need the L&F code present at compile time. Further you don’t bundle any L&F code
in your jar.
Using the Nimbus look & feel that comes with JDK 1.6.0_10+, is tricky since
the class file that implements it might
Selecting L&F On the Command Line
You can also set the default look and
Discovering Installed L&Fs
Discovering Active L&Fs
LookAndFeel laf = UIManager.getLookAndFeel();
String lafName = laf.getName();
Decorating
You can further improve the look with: JFrame.setDefaultLookAndFeelDecorated( true );
L&F Icons
You
Icon closeIcon = UIManager.getIcon( "InternalFrame.closeIcon" );
Overriding
You
UIManager.put( "TabbedPane.selected", Color.RED );
The values you can feed to UIManager.put
are undocumented, but you can learn about them by studying the source code in src.zip
for javax.swing.basic. BasicLookAndFeel. java.
Another approach is to write your own Look & Feel that extends some other one, and just overrides a few
font-defining methods or colour-defining methods. See this sample code for a writing a derived LAF.
Gotchas
Learning More
Sun’s Javadoc on
LookAndFeel class : available:
Sun’s Javadoc on
UIDefaults class : available:
Sun’s Javadoc on
UIManager class : available:
Sun’s JDK Technote Guide on
Nimbus : available:
Books
 |
recommend book⇒Java Look and Feel Design Guidelines (2nd Edition) |
| | paperback |
|---|
| ISBN13: | 978-0-201-72588-9 |
|---|
| publisher: | Addison-Wesley |
| published: | 2001-03-19 |
| by: | Sun Microsystems |
| This book contains no code. It about how to design a good UI using Metal as an example. It contains Sun’s standards for how many pixels to use for various purposes. |
|
 |
recommend book⇒Java Look and Feel Design Guidelines: Advanced Topics |
| | paperback |
|---|
| ISBN13: | 978-0-201-77582-2 |
|---|
| publisher: | Addison-Wesley |
| published: | 2001-12-27 |
| by: | Sun Microsystems |
| It is about how to design a good UI using Metal as an example. |
|
 |
recommend book⇒GUI Bloopers: Don’ts and Do’s for Software Developers and Web Designers |
| | paperback |
|---|
| ISBN13: | 978-1-55860-582-4 |
|---|
| publisher: | Morgan Kaufmann |
| published: | 2000-03-17 |
| by: | Jeff Johnson |
| Works by analysing 82 examples of bad design. |
|
Alloy L&F: commercial, 4 variants, glass effect
changing default fonts
decorated
EaSynth L&F
GUI
Infonode L&F: very simple
JavooToo Look & Feel Collection
JGoodies Looks L&F
JGoodies Looks Plastic L&F
JGoodies Looks Windows L&F
JTattoo L&F: commercial, free for freeware authors, 10 variants
Lipstik L&F: bold high contrast
Liquid L&F: 3D oval clear bubbles
Microsoft Vista User Experience (L&F) guide
Napkin L&F: for presenting prototype ideas, pencil scribbling
NimROD L&F: bold colours, several variants
Office L&F: close copy of Microsoft look
Oyoaha L&F: with many pluggable monochrome themes
Pgs L&F: similar to Vista
Quaqua L&F: like native OS X
skin
SkinLF: over 20 L&Fs, supports GTK and KDE skins
Squareness L&F: minimalist, flat
Substance L&F: with component-level scaling, and skins on top of the L&F. Precise looking
Swing
Synthetica L&F: commercial, bland
Tiny L&F: minimalist, flat
Tonic L&F: like themes used in the Windows NT days