Search code examples
javaswinglook-and-feelmixing

combining customized Java LookAndFeel classes


is there a simple way to combine two customized Java LookAndFeel classes?

I want to use the Nimbus class for its theme (fonts, rounded edges, etc), but with the colors from the Metal class. Short of writing my own customized look and feel class from scratch, I am just wondering if there is a simpler way first. I see that this guy here: Mixing look and feel has customized just a border, but I would like to be able to do this for all the colours. is this possible or would it take just as long to do this as to just write my own class?


Solution

  • http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/color.html

    The above link will guide you to a page to change the color scheme for the Nimbus look and feel. To change the color scheme, at least 3 properties need to be changed. Within the page, there is a link to another page that contains all the properties in the Nimbus look and feel, if you require more changes to the look and feel.

    If you need to retrieve the color scheme for the Metal look and feel, you can use the below piece of code to see all the properties in the Metal look and feel. You will need to identify the correct color properties in this list and then retrieve the colors to be assigned into the 3 properties in the Nimbus look and feel.

    UIDefaults uiDefaults = UIManager.getDefaults();
    Enumeration enum = uiDefaults.keys();
    while (enum.hasMoreElements())
    {
        Object key = enum.nextElement();
        Object val = uiDefaults.get(key);
        System.out.println("[" + key.toString() + "]:[" +
            (null != val ? val.toString() : "(null)") +
            "]");
    }