Search code examples
javaeclipseswingclasspathlook-and-feel

How to use custom look and feel for Swing application?


How to use custom look and feel jar files in Java project For Ex: Seaglass look and feel?

What are the required steps to successfully use any look and feel jar our project and how to add jar file to class path?


Solution

  • I am gonna use seaglass look and feel jar file to explain the answer, you can download the same here

    Step 1: First add the downloaded look and feel to your project classpath

    Right click on your project in eclipse, go to Build path and select configure build path, Under Libraries tab choose Add External Jar and find your Jar file (seaglass jar file in this case). On pressing Ok it shoud appear under Referenced Libraries of your project.

    Step 2: Register LookAndFeel class with UIManager

    try {
    UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
    } catch (Exception e) {
    e.printStackTrace();
    }
    

    Add this code in the JFrame Class constructor. for other look and feel jar file replace "com.seaglasslookandfeel.SeaGlassLookAndFeel" in the code its look and feel class (google it if you cant find).

    You are done, Run your project and there you see the look and Feel you wanted,, Enjoy