10

How could I find out the default selection color in a JList for example?
Where are these colors are stored?

3 Answers 3

15

For Swing components you can get and set the default colors in the application wide UIDefaults provided by the UIManager:

UIDefaults defaults = javax.swing.UIManager.getDefaults();
defaults.getColor("List.selectionBackground");
defaults.getColor("List.selectionForeground");
9

UIMManager Defaults lists all the defaults in a nicely formatted GUI.

2
7
JList.getSelectionForeground();
JList.getSelectionBackground();

for that particular box.

Usually they will be read from SystemColor.textHighlight and SystemColor.textHighlightText at the time the UI is created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.