Swing UIManager.getColor() keys

Jason S picture Jason S · Apr 8, 2009 · Viewed 22.6k times · Source

Is there a list somewhere of the UIManager.getColor() keys for Swing? I can't seem to find it online, just occasional references to strings like "Panel.background" and "Table.selectionBackground".

Answer

Michael Myers picture Michael Myers · Apr 8, 2009

I don't think there is a defined standard set of keys. But you could try this bit of code to list the ones currently available in alphabetical order:

List<String> colors = new ArrayList<String>();
for (Map.Entry<Object, Object> entry : UIManager.getDefaults().entrySet()) {
    if (entry.getValue() instanceof Color) {
        colors.add((String) entry.getKey()); // all the keys are strings
    }
}
Collections.sort(colors);
for (String name : colors)
    System.out.println(name);

This produces a list too long to reproduce here.