How could I find out the default selection color in a JList for example?
Where are these colors are stored?
The default color space for the Java 2D(tm) API is sRGB, a proposed standard RGB color space.
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.
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");
UIMManager Defaults lists all the defaults in a nicely formatted GUI.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With