1. Installing new Look and Feels

Installing other Look and Feels

If you want to install another look and feel that will come up in the getInstalledLookAndFeels, there are 2 ways to do it.
The first is to call UIManager.installLookAndFeel(name, classname) where name is a string representing the look and feel (for use in menus etc) and class is a string pointing to the look and feel (eg javax.swing.plaf.metal.MetalLookAndFeel).

The second way involves a property file and doesn't need the programme to know the look and feel before hand.

In a file called swing.properties which needs to be put in the lib directory of whichever jdk you are using. ie <"java_home">/lib/swing.properties you need to tell it which look and feels are installed and where to find them.

Start with swing.installedlafs = whichever lafs you want
Then for each laf you need
swing.installedlaf.laf.name =
swing.installedlaf.laf.class =

Here is an example:
swing.installedlafs = motif,windows,metal,mac
swing.installedlaf.motif.name = CDE/Motif
swing.installedlaf.motif.class = com.sun.java.swing.plaf.motif.MotifLookAndFeel
swing.installedlaf.windows.name = Windows
swing.installedlaf.windows.class = com.sun.java.swing.plaf.windows.WindowsLookAndFeel
swing.installedlaf.metal.name = Metal
swing.installedlaf.metal.class = javax.swing.plaf.metal.MetalLookAndFeel
swing.installedlaf.mac.name = Mac
swing.installedlaf.mac.class = com.sun.java.swing.plaf.mac.MacLookAndFeel

Back to Java Index
Back to Start Page

Send me email