Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Get Default UI Colors

Tags:

java

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

like image 985
user Avatar asked Sep 13 '10 19:09

user


People also ask

What is the default color in Java?

The default color space for the Java 2D(tm) API is sRGB, a proposed standard RGB color space.

Is color a type in Java?

Java's Color data type represents color values using the RGB color model where a color is defined by three integers (each between 0 and 255) that represent the intensity of the red, green, and blue components of the color. Other color values are obtained by mixing the red, blue and green components.


3 Answers

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");
like image 70
Moritz Avatar answered Oct 15 '22 08:10

Moritz


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

like image 29
camickr Avatar answered Oct 15 '22 09:10

camickr


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.

like image 7
Sanjay Manohar Avatar answered Oct 15 '22 09:10

Sanjay Manohar