The code snippet below describe how we can obtain the available look and feel in the current Swing platform. This information can then be made available to the user, so they can change to look and feel of the application in their preferences.
package org.kodejava.swing;
import javax.swing.UIManager;
public class AvailableLookAndFeel {
public static void main(String[] args) {
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lookAndFeel : lookAndFeels) {
// Get the name of the look and feel
String name = lookAndFeel.getName();
System.out.println("Name = " + name);
// Get the implementation class for the look and feel
String className = lookAndFeel.getClassName();
System.out.println("ClassName = " + className);
}
}
}
Below is the list of available look and feel produces by the code snippet above.
Name = Metal
ClassName = javax.swing.plaf.metal.MetalLookAndFeel
Name = Nimbus
ClassName = javax.swing.plaf.nimbus.NimbusLookAndFeel
Name = CDE/Motif
ClassName = com.sun.java.swing.plaf.motif.MotifLookAndFeel
Name = Windows
ClassName = com.sun.java.swing.plaf.windows.WindowsLookAndFeel
Name = Windows Classic
ClassName = com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel
Latest posts by Wayan (see all)
- How do I create a string of repeated characters? - September 1, 2023
- How do I convert datetime string with optional part to a date object? - August 28, 2023
- How do I split large excel file into multiple smaller files? - April 15, 2023