Introduction
In this article we are going to explain that the SystemColor class provides a standard set of symbolic colors representing each distinct type of color on the desktop. It is common for platform desktops (Windows 95, Solaris/CDE, etc.) to provide a color scheme for objects on the desktop, and typically this scheme is configurable by the user. It is usually desirable to have applications running on that desktop use that color scheme in order to maintain visual consistency.
There are the following symbolic color objects created automatically and stored statically in java.awt.SystemColor.
Description of Some general Fields :
1-desktop - This is the Background Color of your desktop.
Syntax
public final static SystemColor desktop;
2-activeCaption - This is color of system caption.
Syntax
public final static SystemColor activeCaption;
3-activeCaptionText - This fields return the color of caption text.
Syntax
public final static SystemColor activeCaptionText;
4-activeCaptionBorder - This fields returns the color of caption borders.
Syntax
public final static SystemColor activeCaptionBorer
5-menu - This fields return the Background color of menus.
Syntax
public final static SystemColor menu.
Remains Fields listed following:
public final static SystemColor controlText;
public final static SystemColor controlLtHighlight;
public final static SystemColor controlHighlight;
public final static SystemColor controlShadow;
public final static SystemColor controlDkShadow;
public final static SystemColor inactiveControlText;
public final static SystemColor scrollbar;
public final static SystemColor info;
public final static SystemColor deskto;
public final static SystemColor activeCaption;
public final static SystemColor activeCaptionext;
public final static SystemColor activeCaptionBorer;
public final static SystemColor inactiveCaption;
public final static SystemColor inactiveCaptionText;
public final static SystemColor inactiveCaptionBorder;
public final static SystemColor window;
public final static SystemColor windowBorder;
public final static SystemColor infoText;
public final static SystemColor windowText;
public final static SystemColor menu;
public final static SystemColor menuext;
public final static SystemColor text;
public final static SystemColor textext;
public final static SystemColor textHiglight;
public final static SystemColor textHighlighText;
public final static SystemColor control;
In the following example we are going to show most of the colors we show by using the set background color of the frame. And we use a color array[] for storing colors which are obtained by the previous methods.
In this program we want to try to show most of the color's id shown by cmd.
Example
import java.awt.*;
import java.awt.SystemColor;
public class SystemColorDemo {
public static void main(String[] a) {
Color[] sysColor = new Color[] {
SystemColor.activeCaption,
SystemColor.activeCaptionBorder, SystemColor.activeCaptionText,
SystemColor.control, SystemColor.controlDkShadow,
SystemColor.controlHighlight, SystemColor.controlLtHighlight,
SystemColor.controlShadow, SystemColor.controlText,
SystemColor.desktop, SystemColor.inactiveCaption,
SystemColor.inactiveCaptionBorder,
SystemColor.inactiveCaptionText, SystemColor.info,
SystemColor.infoText, SystemColor.menu, SystemColor.menuText,
SystemColor.scrollbar, SystemColor.text,
SystemColor.textHighlight, SystemColor.textHighlightText,
SystemColor.textInactiveText, SystemColor.textText,
SystemColor.window, SystemColor.windowBorder,
SystemColor.windowText };
for (Color c : sysColor) {
System.out.println(c);
Frame f = new Frame("colors");
f.setSize(200, 200);
f.setVisible(true);
f.setBackground(c);
}
}
}
OUTPUT
This is the initial output of the cmd and it shows all the colors which are stored in the color array by using its fields.
These are various colors as backgrounds of the following frame used by the system; it's not all the colors of your system; it's just a Demo.