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".
回答1:
I was looking for the same thing and found this page as well as an excellent overview of all these properties on http://nadeausoftware.com/node/85.
回答2:
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 colors = new ArrayList(); for (Map.Entry
This produces a list too long to reproduce here.
回答3:
@mmyers got me inspired. Here's a short program to list the UIManager defaults in a sortable table.
package com.example.test.gui; import java.awt.Color; import java.awt.Component; import java.util.Map; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.UIManager; import javax.swing.table.DefaultTableCellRenderer; import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.GlazedLists; import ca.odell.glazedlists.SortedList; import ca.odell.glazedlists.gui.AbstractTableComparatorChooser; import ca.odell.glazedlists.gui.TableFormat; import ca.odell.glazedlists.swing.EventTableModel; import ca.odell.glazedlists.swing.TableComparatorChooser; public class UIManagerDefaultsViewer { public static class UIEntry { final private String key; final private Object value; UIEntry(Map.Entry
It lacks search, but it can filter by component or value type, which is pretty great.
回答5:
They are kind of Look and Feel implementation dependent. Look in BasicLookAndFeel.java for the basic keys. Don't expect all PL&F to behave the same, or even remain the same between versions.