Java tip: SystemColors for Mac OS X user interface themes

Technologies: Java 5+

Both Mac themes and all eight user-selectable highlight colors set the color scheme for window title bars, buttons, check boxes, and other user interface components. For Java applications, changing the theme also sets colors in Java's java.awt.SystemColor objects, which applications may use to customize their user interfaces to match the current theme.

This article discusses SystemColor problems on Macs, and provides color swatches, RGB/HSV values, and downloadable color lists for all SystemColors for the standard Mac theme and highlight colors.

This article is part of a series on How to use SystemColors to access OS user interface theme colors that catalogs Java's SystemColors for user interface themes in major OSes. The color catalogs provide a resource for comparing theme colors and creating custom Java components that match the themes.

Accessing Mac OS X theme colors from Java

A Mac theme defines the color scheme for window title bars, buttons, and so forth. Mac OS X's iconic glassy blue buttons, gray gradient window frames, and red/yellow/green title bar buttons are all part of its theme.

Java's java.awt.SystemColor class provides access to well-defined theme colors, such as the foreground and background colors for buttons, text fields, and menus. Each theme color has a static SystemColor object. For instance, SystemColor.textHighlight is the background color for selected text in a text field.

A list of SystemColor objects and their use is discussed further in the lead series article. The following article discusses Mac-specific issues, summarizes Mac user theme choices, and provides color swatches and RGB values for theme SystemColors.

Selecting Mac OS X themes

Briefly, Mac OS X themes are selected at the top of the Appearance preferences pane:

Mac appearance preferences pane
Figure 1. Theme selections in the
Mac OS X Appearance preferences pane.

Macs have just two themes: Blue (the default) and Graphite. The individual colors for window title bars, window backgrounds, buttons, text, and so forth are all defined by these two themes.

Unlike Windows and Linux themes, Mac themes cannot be changed and users cannot add new themes. The only user configurable color choice is the Highlight color used to indicate selected text and list items. The Highlight color menu includes eight standard colors: Graphite, Silver, Blue (the default), Gold, Red, Orange, Green, and Purple. Users can also select a custom highlight color.

Selecting a highlight color sets the background color of selected text. Mac OS X automatically computes a second darker color to use for selected list and table items.

Mac theme highlight color examples
Figure 2. Mac theme highlight color examples for Blue and Red choices.

Dealing with Mac SystemColor problems

Java's SystemColor class is a flawed approach to accessing OS theme settings. While colors are defined for button backgrounds and text, none are defined for tabs, checkboxes, radio buttons, progress bars, and more. Though a highlight color is defined for selected text, none are defined for selected menu items, toggle buttons, radio buttons, or checkboxes. Beyond colors, Java has no access to OS theme fonts, button styles, window title bar buttons, and so forth. So, while there are specific problems on the Mac (and every OS), the primary problem is that Java's theme access is flawed.

Some specific problems on the Mac include:

  • SystemColor.activeCaption and SystemColor.inactiveCaption are intended to give the window title bar background color for front and back windows. On the Mac, these are set to white and gray, and neither color is correct for the Mac's gray gradient title bars.
  • SystemColor.activeCaptionBorder and SystemColor.inactiveCaptionBorder are intended to indicate a border color around front and back windows. On the Mac, there are no window borders and both of these color settings are irrelevant and default to white and gray.
  • SystemColor.control is intended to give the background color for buttons and panels. On the Mac, this is incorrectly set to white. The correct control background color is light gray. However, while window backgrounds use this color, the Mac's buttons, tabs, scrollbar thumbs, etc., are all drawn with a glassy blue or gray appearance for the Blue or Graphite themes. The blue or gray color in use has no corresponding SystemColor.
  • SystemColor.info is intended to give the background color for tool tips. On the Mac, this is incorrectly set to white. The correct tool tip background color is light yellow.
  • SystemColor.desktop is intended to give the desktop color, even though most users use a favorite image as their desktop. On the Mac, SystemColor.desktop is always an unexpected bright green.
  • SystemColor.controlHighlight is intended as one of the highlight and shadow colors for beveled buttons. Very few themes use bevels any more, so on the Mac SystemColor.controlHighlight is repurposed as the color for halos outlining the component with the keyboard focus. While this is useful, no other OS sets this SystemColor like this, so cross-platform Java applications can't count on it. And Java doesn't provide a SystemColor dedicated to focus halos.

None of these have workarounds except for SystemColor.control. The correct light gray button and panel background color is available as the "control" UIDefault for the native Mac look and feel. This color can be retrieved and used whether or not your application chooses to use the native look.

Color swatches and values

Selecting a new theme or changing the theme's highlight colors immediately updates one or more Java SystemColors.

Blue and Graphite themes

The Blue and Graphite themes are nearly identical. The Blue theme uses shiny blue components and red, yellow, and green window title bar buttons. The Graphite theme uses shiny gray components and gray title bar buttons. Both themes have the same Java SystemColor values.

Name Hex triplet Red Green Blue Hue Satur. Value
activeCaption #ffffff 255 255 255 0 0 100
activeCaptionBorder #ffffff 255 255 255 0 0 100
activeCaptionText #000000 0 0 0 0 0 0
control #ffffff 255 255 255 0 0 100
controlDkShadow #000000 0 0 0 0 0 0
controlHighlight #0063cd 0 99 205 211 100 80
controlLtHighlight #ffffff 255 255 255 0 0 100
controlShadow #8e8e8e 142 142 142 0 0 55
controlText #000000 0 0 0 0 0 0
desktop #00ff00 0 255 0 120 100 100
inactiveCaption #808080 128 128 128 0 0 50
inactiveCaptionBorder #808080 128 128 128 0 0 50
inactiveCaptionText #808080 128 128 128 0 0 50
info #ffffff 255 255 255 0 0 100
infoText #000000 0 0 0 0 0 0
menu #ffffff 255 255 255 0 0 100
menuText #000000 0 0 0 0 0 0
scrollbar #9a9a9a 154 154 154 0 0 60
text #ffffff 255 255 255 0 0 100
textHighlight #93cdff 147 205 255 207 42 100
textHighlightText #000000 0 0 0 0 0 0
textInactiveText #6c6c6c 108 108 108 0 0 42
textText #000000 0 0 0 0 0 0
window #ffffff 255 255 255 0 0 100
windowBorder #9a9a9a 154 154 154 0 0 60
windowText #000000 0 0 0 0 0 0

Highlight colors

The Mac's highlight color choices change SystemColor.controlHighlight and SystemColor.textHighlight while leaving the others unchanged:

Blue highlight color (default)
Name Hex triplet Red Green Blue Hue Satur. Value
controlHighlight #0063cd 0 99 205 211 100 80
textHighlight #93cdff 147 205 255 207 42 100
Gold highlight color
Name Hex triplet Red Green Blue Hue Satur. Value
controlHighlight #ffaf18 255 175 24 28 86 68
textHighlight #ffe861 255 232 97 49 58 90
Graphite highlight color
Name Hex triplet Red Green Blue Hue Satur. Value
controlHighlight #577287 87 114 135 206 35 52
textHighlight #b6c6d2 182 198 210 205 13 82
Green highlight color
Name Hex triplet Red Green Blue Hue Satur. Value
controlHighlight #00bd3a 0 189 58 138 100 74
textHighlight #9afb80 154 251 128 107 49 98
Orange highlight color
Name Hex triplet Red Green Blue Hue Satur. Value
controlHighlight #ff6c16 255 108 22 317 79 42
textHighlight #ffc56e 255 197 110 20 44 77
Purple highlight color
Name Hex triplet Red Green Blue Hue Satur. Value
controlHighlight #8837a9 136 55 169 282 67 66
textHighlight #f5a5fe 245 165 254 293 35 99
Red highlight color
Name Hex triplet Red Green Blue Hue Satur. Value
controlHighlight #ff1935 255 25 53 372 52 20
textHighlight #ff9b78 255 155 120 248 22 60
Silver highlight color
Name Hex triplet Red Green Blue Hue Satur. Value
controlHighlight #6c6c6c 108 108 108 0 0 42
textHighlight #bababa 186 186 186 0 0 72

Downloads

The Blue and Graphite theme SystemColors with the default blue highlight color are available for download in the X11 rgb.txt file format:

Each of the highlight colors are available in additional color files:

Further reading

Related articles at NadeauSoftware.com

Web articles

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

Nadeau software consulting
Nadeau software consulting