< prev index next >

src/java.desktop/share/classes/java/awt/SystemColor.java

Print this page




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.awt;
  26 
  27 import sun.awt.AWTAccessor;
  28 
  29 import java.io.ObjectStreamException;
  30 
  31 import java.lang.annotation.Native;
  32 
  33 /**
  34  * A class to encapsulate symbolic colors representing the color of
  35  * native GUI objects on a system.  For systems which support the dynamic
  36  * update of the system colors (when the user changes the colors)
  37  * the actual RGB values of these symbolic colors will also change
  38  * dynamically.  In order to compare the "current" RGB value of a
  39  * <code>SystemColor</code> object with a non-symbolic Color object,
  40  * <code>getRGB</code> should be used rather than <code>equals</code>.
  41  * <p>
  42  * Note that the way in which these system colors are applied to GUI objects
  43  * may vary slightly from platform to platform since GUI objects may be
  44  * rendered differently on each platform.
  45  * <p>
  46  * System color values may also be available through the <code>getDesktopProperty</code>
  47  * method on <code>java.awt.Toolkit</code>.
  48  *
  49  * @see Toolkit#getDesktopProperty
  50  *
  51  * @author      Carl Quinn
  52  * @author      Amy Fowler
  53  */
  54 public final class SystemColor extends Color implements java.io.Serializable {
  55 
  56    /**
  57      * The array index for the
  58      * {@link #desktop} system color.
  59      * @see SystemColor#desktop
  60      */
  61     @Native public static final int DESKTOP = 0;
  62 
  63     /**
  64      * The array index for the
  65      * {@link #activeCaption} system color.
  66      * @see SystemColor#activeCaption
  67      */


 363 
 364     /**
 365      * The color rendered for the text of inactive items, such as in menus.
 366      */
 367     public static final SystemColor textInactiveText = new SystemColor((byte)TEXT_INACTIVE_TEXT);
 368 
 369     /**
 370      * The color rendered for the background of control panels and control objects,
 371      * such as pushbuttons.
 372      */
 373     public static final SystemColor control = new SystemColor((byte)CONTROL);
 374 
 375     /**
 376      * The color rendered for the text of control panels and control objects,
 377      * such as pushbuttons.
 378      */
 379     public static final SystemColor controlText = new SystemColor((byte)CONTROL_TEXT);
 380 
 381     /**
 382      * The color rendered for light areas of 3D control objects, such as pushbuttons.
 383      * This color is typically derived from the <code>control</code> background color
 384      * to provide a 3D effect.
 385      */
 386     public static final SystemColor controlHighlight = new SystemColor((byte)CONTROL_HIGHLIGHT);
 387 
 388     /**
 389      * The color rendered for highlight areas of 3D control objects, such as pushbuttons.
 390      * This color is typically derived from the <code>control</code> background color
 391      * to provide a 3D effect.
 392      */
 393     public static final SystemColor controlLtHighlight = new SystemColor((byte)CONTROL_LT_HIGHLIGHT);
 394 
 395     /**
 396      * The color rendered for shadow areas of 3D control objects, such as pushbuttons.
 397      * This color is typically derived from the <code>control</code> background color
 398      * to provide a 3D effect.
 399      */
 400     public static final SystemColor controlShadow = new SystemColor((byte)CONTROL_SHADOW);
 401 
 402     /**
 403      * The color rendered for dark shadow areas on 3D control objects, such as pushbuttons.
 404      * This color is typically derived from the <code>control</code> background color
 405      * to provide a 3D effect.
 406      */
 407     public static final SystemColor controlDkShadow = new SystemColor((byte)CONTROL_DK_SHADOW);
 408 
 409     /**
 410      * The color rendered for the background of scrollbars.
 411      */
 412     public static final SystemColor scrollbar = new SystemColor((byte)SCROLLBAR);
 413 
 414     /**
 415      * The color rendered for the background of tooltips or spot help.
 416      */
 417     public static final SystemColor info = new SystemColor((byte)INFO);
 418 
 419     /**
 420      * The color rendered for the text of tooltips or spot help.
 421      */
 422     public static final SystemColor infoText = new SystemColor((byte)INFO_TEXT);
 423 
 424     /*


 470      */
 471     private static void updateSystemColors() {
 472         if (!GraphicsEnvironment.isHeadless()) {
 473             Toolkit.getDefaultToolkit().loadSystemColors(systemColors);
 474         }
 475         for (int i = 0; i < systemColors.length; i++) {
 476             systemColorObjects[i].value = systemColors[i];
 477         }
 478     }
 479 
 480     /**
 481      * Creates a symbolic color that represents an indexed entry into system
 482      * color cache. Used by above static system colors.
 483      */
 484     private SystemColor(byte index) {
 485         super(systemColors[index]);
 486         this.index = index;
 487     }
 488 
 489     /**
 490      * Returns a string representation of this <code>Color</code>'s values.
 491      * This method is intended to be used only for debugging purposes,
 492      * and the content and format of the returned string may vary between
 493      * implementations.
 494      * The returned string may be empty but may not be <code>null</code>.
 495      *
 496      * @return  a string representation of this <code>Color</code>
 497      */
 498     public String toString() {
 499         return getClass().getName() + "[i=" + (index) + "]";
 500     }
 501 
 502     /**
 503      * The design of the {@code SystemColor} class assumes that
 504      * the {@code SystemColor} object instances stored in the
 505      * static final fields above are the only instances that can
 506      * be used by developers.
 507      * This method helps maintain those limits on instantiation
 508      * by using the index stored in the value field of the
 509      * serialized form of the object to replace the serialized
 510      * object with the equivalent static object constant field
 511      * of {@code SystemColor}.
 512      * See the {@link #writeReplace} method for more information
 513      * on the serialized form of these objects.
 514      * @return one of the {@code SystemColor} static object
 515      *         fields that refers to the same system color.
 516      */




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.awt;
  26 
  27 import sun.awt.AWTAccessor;
  28 
  29 import java.io.ObjectStreamException;
  30 
  31 import java.lang.annotation.Native;
  32 
  33 /**
  34  * A class to encapsulate symbolic colors representing the color of
  35  * native GUI objects on a system.  For systems which support the dynamic
  36  * update of the system colors (when the user changes the colors)
  37  * the actual RGB values of these symbolic colors will also change
  38  * dynamically.  In order to compare the "current" RGB value of a
  39  * {@code SystemColor} object with a non-symbolic Color object,
  40  * {@code getRGB} should be used rather than {@code equals}.
  41  * <p>
  42  * Note that the way in which these system colors are applied to GUI objects
  43  * may vary slightly from platform to platform since GUI objects may be
  44  * rendered differently on each platform.
  45  * <p>
  46  * System color values may also be available through the {@code getDesktopProperty}
  47  * method on {@code java.awt.Toolkit}.
  48  *
  49  * @see Toolkit#getDesktopProperty
  50  *
  51  * @author      Carl Quinn
  52  * @author      Amy Fowler
  53  */
  54 public final class SystemColor extends Color implements java.io.Serializable {
  55 
  56    /**
  57      * The array index for the
  58      * {@link #desktop} system color.
  59      * @see SystemColor#desktop
  60      */
  61     @Native public static final int DESKTOP = 0;
  62 
  63     /**
  64      * The array index for the
  65      * {@link #activeCaption} system color.
  66      * @see SystemColor#activeCaption
  67      */


 363 
 364     /**
 365      * The color rendered for the text of inactive items, such as in menus.
 366      */
 367     public static final SystemColor textInactiveText = new SystemColor((byte)TEXT_INACTIVE_TEXT);
 368 
 369     /**
 370      * The color rendered for the background of control panels and control objects,
 371      * such as pushbuttons.
 372      */
 373     public static final SystemColor control = new SystemColor((byte)CONTROL);
 374 
 375     /**
 376      * The color rendered for the text of control panels and control objects,
 377      * such as pushbuttons.
 378      */
 379     public static final SystemColor controlText = new SystemColor((byte)CONTROL_TEXT);
 380 
 381     /**
 382      * The color rendered for light areas of 3D control objects, such as pushbuttons.
 383      * This color is typically derived from the {@code control} background color
 384      * to provide a 3D effect.
 385      */
 386     public static final SystemColor controlHighlight = new SystemColor((byte)CONTROL_HIGHLIGHT);
 387 
 388     /**
 389      * The color rendered for highlight areas of 3D control objects, such as pushbuttons.
 390      * This color is typically derived from the {@code control} background color
 391      * to provide a 3D effect.
 392      */
 393     public static final SystemColor controlLtHighlight = new SystemColor((byte)CONTROL_LT_HIGHLIGHT);
 394 
 395     /**
 396      * The color rendered for shadow areas of 3D control objects, such as pushbuttons.
 397      * This color is typically derived from the {@code control} background color
 398      * to provide a 3D effect.
 399      */
 400     public static final SystemColor controlShadow = new SystemColor((byte)CONTROL_SHADOW);
 401 
 402     /**
 403      * The color rendered for dark shadow areas on 3D control objects, such as pushbuttons.
 404      * This color is typically derived from the {@code control} background color
 405      * to provide a 3D effect.
 406      */
 407     public static final SystemColor controlDkShadow = new SystemColor((byte)CONTROL_DK_SHADOW);
 408 
 409     /**
 410      * The color rendered for the background of scrollbars.
 411      */
 412     public static final SystemColor scrollbar = new SystemColor((byte)SCROLLBAR);
 413 
 414     /**
 415      * The color rendered for the background of tooltips or spot help.
 416      */
 417     public static final SystemColor info = new SystemColor((byte)INFO);
 418 
 419     /**
 420      * The color rendered for the text of tooltips or spot help.
 421      */
 422     public static final SystemColor infoText = new SystemColor((byte)INFO_TEXT);
 423 
 424     /*


 470      */
 471     private static void updateSystemColors() {
 472         if (!GraphicsEnvironment.isHeadless()) {
 473             Toolkit.getDefaultToolkit().loadSystemColors(systemColors);
 474         }
 475         for (int i = 0; i < systemColors.length; i++) {
 476             systemColorObjects[i].value = systemColors[i];
 477         }
 478     }
 479 
 480     /**
 481      * Creates a symbolic color that represents an indexed entry into system
 482      * color cache. Used by above static system colors.
 483      */
 484     private SystemColor(byte index) {
 485         super(systemColors[index]);
 486         this.index = index;
 487     }
 488 
 489     /**
 490      * Returns a string representation of this {@code Color}'s values.
 491      * This method is intended to be used only for debugging purposes,
 492      * and the content and format of the returned string may vary between
 493      * implementations.
 494      * The returned string may be empty but may not be {@code null}.
 495      *
 496      * @return  a string representation of this {@code Color}
 497      */
 498     public String toString() {
 499         return getClass().getName() + "[i=" + (index) + "]";
 500     }
 501 
 502     /**
 503      * The design of the {@code SystemColor} class assumes that
 504      * the {@code SystemColor} object instances stored in the
 505      * static final fields above are the only instances that can
 506      * be used by developers.
 507      * This method helps maintain those limits on instantiation
 508      * by using the index stored in the value field of the
 509      * serialized form of the object to replace the serialized
 510      * object with the equivalent static object constant field
 511      * of {@code SystemColor}.
 512      * See the {@link #writeReplace} method for more information
 513      * on the serialized form of these objects.
 514      * @return one of the {@code SystemColor} static object
 515      *         fields that refers to the same system color.
 516      */


< prev index next >