user
user

Reputation: 6797

Java Get Default UI Colors

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

Upvotes: 10

Views: 9993

Answers (3)

camickr
camickr

Reputation: 324147

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

Upvotes: 9

Moritz
Moritz

Reputation: 14212

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");

Upvotes: 15

Sanjay Manohar
Sanjay Manohar

Reputation: 7026

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.

Upvotes: 7

Related Questions