java examples
Home Java Examples Resources Java Interview Questions
Brainpower SEO

How to get the available swing look and feel?

The code snippet below describe how we can obtain the available look and feel in the current swing platform. These information can then be made available to the user so they can change to look and feel of the application in their preferences.

package com.javacoderanch.example.swing;

import javax.swing.*;

public class AvailableLookAndFeel {
    public static void main(String[] args) {
        UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
        for (int i = 0; i < lookAndFeelInfos.length; i++) {
            UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];

            //
            // Get the name of the look and feel 
            //
            String name = lookAndFeelInfo.getName();            
            System.out.println("name = " + name);
            
            //
            // Get the implementation class for the look and feel
            //
            String className = lookAndFeelInfo.getClassName();
            System.out.println("className = " + className);
        }
    }
}