Java – How to setup LookAndFeel Files in Java

gtkjavalook-and-feelqtswing

I need to setup LookAndFeel Files in JDK 1.6.
I have two files:

  1. napkinlaf-swingset2.jar

  2. napkinlaf.jar

How can I set this up and use it?

I would like a GTK look and feel OR Qt look and feel, Are they available?

Best Solution

This page explains how the work with Look&Feels: http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html

You can do it commandline:

java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel MyApp

Or in code:

UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

You need to make sure the jars containing the look&feel are on the application classpath. How this works depends on the application. A typical way would be to put it in a lib folder.

Look&Feels that are available by default in the JDK are:

com.sun.java.swing.plaf.gtk.GTKLookAndFeel
com.sun.java.swing.plaf.motif.MotifLookAndFeel
com.sun.java.swing.plaf.windows.WindowsLookAndFeel

Quioting the link above:

The GTK+ L&F will only run on UNIX or Linux systems with GTK+ 2.2 or later installed, while the Windows L&F runs only on Windows systems. Like the Java (Metal) L&F, the Motif L&F will run on any platform.