Example usage for javax.swing.plaf ColorUIResource ColorUIResource

List of usage examples for javax.swing.plaf ColorUIResource ColorUIResource

Introduction

In this page you can find the example usage for javax.swing.plaf ColorUIResource ColorUIResource.

Prototype

public ColorUIResource(Color c) 

Source Link

Document

Constructs a ColorUIResource .

Usage

From source file:org.tellervo.desktop.prefs.Prefs.java

private void installUIDefault(Class<? extends Object> type, String prefskey, String uikey) {
    Object decoded = null;//from   ww w .j  av  a2  s. co  m
    String pref = prefs.getProperty(prefskey);
    if (pref == null) {
        log.warn("Preference '" + prefskey + "' held null value.");
        return;
    }
    if (Color.class.isAssignableFrom(type)) {
        decoded = Color.decode(pref);
    } else if (Font.class.isAssignableFrom(type)) {
        decoded = Font.decode(pref);
    } else {
        log.warn("Unsupported UIDefault preference type: " + type);
        return;
    }

    if (decoded == null) {
        log.warn("UIDefaults color preference '" + prefskey + "' was not decodable.");
        return;
    }

    UIDefaults uidefaults = UIManager.getDefaults();
    // if (uidefaults.contains(property)) {
    // NOTE: ok, UIDefaults object is strange. Not only does
    // it not implement the Map interface correctly, but entries
    // will not "stick". The entries must be first explicitly
    // removed, and then re-added - aaron
    log.debug("Removing UIDefaults key before overwriting: " + uikey);
    uidefaults.remove(uikey);
    // }

    if (Color.class.isAssignableFrom(type)) {
        uidefaults.put(uikey, new ColorUIResource((Color) decoded));
    } else {
        uidefaults.put(uikey, new FontUIResource((Font) decoded));
    }
}