Search code examples
javaswinguser-interfacelook-and-feel

What steps do I need to take in order to change the 'look and feel' of java swing GUI?


I have just found a nice look that I would like to use for my programs appearance however I'm unsure of how to integrate it. This is the look i'm after:

AcrylLookAndFeel

I have managed to find the website and download a jar file which I have included in my build path. I have also found the following line of code which I have included:

UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");

When I run it I don't get any errors, however it doesn't look anything like the image. Have I missed out steps? What do I need to do?

One other concern I have is that I'm currently working on a mac, however I want the appearance to be consistent regardless of whether I run my program on a mac or on windows. Is this even possible? If so please could you advise how to do this (if any changes are required)?


Solution

  • Setting the Swing look and feel in Java carries over between operating systems. I've always only ever done it before I created my Swing GUI.

    public static void main(String[] args) {
        try {    
            UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
        } 
        // Probably want to break this into handling the various exceptions that can be thrown.
        catch (Exception e) {
           // handle exception
        }
    
        // Create Swing GUI and so forth
    }