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 get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024