Java tip: Problems and special features of the CDE/Motif look and feel, part 2

Technologies: Java 5+

This part 2 of 4 articles continues a component by component review of problems, workarounds, and special features for the classic Java Swing CDE/Motif look and feel. Example images are included along with UIDefaults values, color swatches, and icon images.

Part 1 of this series reviewed how to select the look and feel and access its UIDefaults, then started an alphabetical run through its components from JButton through JEditorPane. Part 2 here covers JFileChooser through JOptionPane. Part 3 covers JPanel through JSplitPane. And Part 4 covers JTabbedPane through JViewport.

Working with the CDE/Motif look and feel

Below continues an alphabetical run through the look and feel's UIDefaults and Swing components. Non-string keys and UI class values are implementation artifacts and are not included here.


Key Type Value
FileChooser.ancestorInputMap Input map javax.swing.plaf.InputMapUIResource
FileChooser.enterFileNameLabelMnemonic Integer 78
FileChooser.filesLabelMnemonic Integer 73
FileChooser.filterLabelMnemonic Integer 82
FileChooser.foldersLabelMnemonic Integer 76
FileChooser.pathLabelMnemonic Integer 80
FileChooser.readOnly Boolean false
FileChooser.useSystemExtensionHiding Boolean false
FileChooser.usesSingleFilePane Boolean false


  • The default size of a JFileChooser is wide enough for the entire absolute file path to the starting directory. The longer the path, the bigger the dialog box! You can prevent this unfortunate behavior by setting the size of the chooser explicitly with setSize( Dimension d ) (other look and feels don't have this behavior).
  • The default accept-all file filter's description in the filter menu is "*" instead of the typical "All Files". You can override this by disabling the default accept-all filter with setAcceptAllFileFilterUsed( false ), and then create and add your own accept-all filter with addChoosableFileFilter( FileFilter f ) using any menu text you like.
  • The default approve button text for an open dialog is "OK" instead of the usual "Open". You can correct this by calling setApproveButtonText( String s ).
  • The "OK" button is enabled even when no files or folders are selected, but pressing it does nothing until a file is chosen (other look and feels disable the button until a file is selected).
  • The "Help" button is always present, but always disabled. It's hard-coded that way. There is no way to install an action listener to respond to the button without burrowing through the component's children to find an unnamed button with a "Help" label.
  • There is no "New Folder" button (most look and feels include such a button).
  • None of the dialog's buttons are initially marked as the dialog's default button (some look and feels set a default, and some do not). Pressing tab cycles the keyboard focus through the chooser's components and will make any button with the focus the default button.
  • The buttons along the bottom don't have uniform size and they stretch as the chooser is resized. This looks sloppy and it cannot be corrected without digging through the component's children and overriding the layout.
  • The bottom buttons are crowded against the bottom of the chooser. When one of the buttons is marked as the default, its groove around the button and pink keyboard focus outline go right to the edge of the chooser. You can't add border space when using the showOpenDialog( Component c ) or showSaveDialog( Component c ) methods. Instead, you can create your own JDialog, add an EmptyBorder to the dialog's content pane, then add the JFileChooser. This also lets you set the size of the dialog box so that it isn't as wide as the directory path.
  • The chooser includes a transparent gap between the opaque upper and lower panels. If you're using a parent container with a different background color, it'll show through here. But you can't make the parent's color show through for the rest of the panel without digging through the chooser's child components, which will give you implementation dependent results. There are no standard methods on JFileChooser to get the child panels.
  • The file chooser is not the native Mac, Windows, or Linux file chooser users are likely to be familiar with. Its non-standard appearance and layout may confuse users.
  • The placement of buttons along the bottom of the dialogs is not consistent with native platform conventions. For the Mac, Windows, and Linux, dialog button conventions right-align all buttons instead of spreading them out. On the Mac, the approve button should be right-most, while for Windows it should be left-most.


Key Type Value
FormattedTextField.background Color 174, 178, 195
FormattedTextField.border Border javax.swing.plaf.basic.BasicBorders$FieldBorder
FormattedTextField.caretBlinkRate Integer 500
FormattedTextField.caretForeground Color 0, 0, 0
FormattedTextField.focusInputMap Input map javax.swing.plaf.InputMapUIResource
FormattedTextField.font Font SansSerif, 12.0
FormattedTextField.foreground Color 0, 0, 0
FormattedTextField.inactiveBackground Color 174, 178, 195
FormattedTextField.inactiveForeground Color 128, 128, 128
FormattedTextField.margin Insets 0, 0, 0, 0
FormattedTextField.selectionBackground Color 0, 0, 0
FormattedTextField.selectionForeground Color 255, 247, 233

Special features

  • The UIDefaults "FormattedTextField.border" contains a border object that draws the recessed beveled border around the text field.



  • An editable JFormattedTextField only indicates the keyboard focus with a black caret. The component doesn't draw the pink outline used by most components to indicate the focus.
  • The field's text is crowded against the edges of the component border. You can increase the margins with setMargin( Insets m ).


Key Type Value
InternalFrame.activeTitleBackground Color 178, 77, 122
InternalFrame.activeTitleForeground Color 255, 255, 255
InternalFrame.border Border javax.swing.plaf.BorderUIResource$CompoundBorderUIResource
InternalFrame.borderColor Color 174, 178, 195
InternalFrame.borderDarkShadow Color 0, 0, 0
InternalFrame.borderHighlight Color 220, 222, 229
InternalFrame.borderLight Color 220, 222, 229
InternalFrame.borderShadow Color 99, 101, 111
InternalFrame.closeIcon Icon javax.swing.plaf.basic.BasicIconFactory$EmptyFrameIcon
InternalFrame.icon Icon sun.swing.ImageIconUIResource
InternalFrame.iconifyIcon Icon javax.swing.plaf.basic.BasicIconFactory$EmptyFrameIcon
InternalFrame.inactiveTitleBackground Color 174, 178, 195
InternalFrame.inactiveTitleForeground Color 0, 0, 0
InternalFrame.maximizeIcon Icon javax.swing.plaf.basic.BasicIconFactory$EmptyFrameIcon
InternalFrame.minimizeIcon Icon javax.swing.plaf.basic.BasicIconFactory$EmptyFrameIcon
InternalFrame.titleFont Font Dialog, 12.0
InternalFrame.windowBindings Array java.lang.Object
InternalFrameTitlePane.closeButtonOpacity Boolean true
InternalFrameTitlePane.iconifyButtonOpacity Boolean true
InternalFrameTitlePane.maximizeButtonOpacity Boolean true

Special features

  • The UIDefaults "InternalFrame.border" gives a border object that draws a frame's thick beveled border, but not the title bar. You can use the border to give a frame-like look to any component, such as a JPanel, though it will only show resize corners on a JInternalFrame subclass.



  • Except for "InternalFrame.icon", all of the UIDefaults icons are empty. "InternalFrame.icon" contains a small unused Java cup icon. There are no UIDefaults icons for the actual title bar icons (some look and feels provide them, and some do not).

    16 x 16
  • Any frame icon set with setFrameIcon( Icon i ) is ignored (most look and feels show the frame icon on the title bar).
  • There is no way to set the desktop icon for an iconified JInternalFrame. The JDesktopPane default icon is always used (most look and feels instead use the frame icon as the desktop icon).
  • There is no visual difference between an enabled and disabled JInternalFrame (some look and feels dim the frame's title bar colors when the frame is disabled).
  • The frame's decorations depend upon its configured abilities (most look and feels do something similar). The title bar's big square button on the right is present if the frame is maximizable. The small square button beside it is present if the frame is iconifiable. The corner marks on all four frame corners are present if the frame is resizable. The dash button on the title bar is always present and shows a pull-down menu of frame operations.
  • There is no way to control the title bar menu's colors or content. It always contains menu items for "Restore", "Move", "Size", "Minimize", "Maximize", and "Close". These names may not match the native platform conventions. For instance, on the Mac the "Maximize" item should be "Zoom" and "Restore" should be "Open."
  • The "Move" and "Size" menu items on the title bar menu are always disabled. They're hard-coded that way.
  • The look and feel of the JInternalFrame title bar buttons has nothing to do with the conventions of the native platform, so they may leave users confused about which button does what.


Key Type Value
Label.background Color 174, 178, 195
Label.disabledForeground Color 255, 255, 255
Label.disabledShadow Color 99, 101, 111
Label.font Font Dialog, 12.0
Label.foreground Color 0, 0, 0


  • Disabled text is not drawn with the UIDefaults "Label.disabledForeground" or "Label.disabledShadow" colors. Instead it's always drawn using a pair of light and dark colors calculated from the current background color using the Color class's brighter( ) and darker( ) methods. While the disabled text color cannot be set directly, the component's background color used to calculate the disabled colors can be set using setBackground( Color c ).


Key Type Value
List.background Color 174, 178, 195
List.cellRenderer Object javax.swing.DefaultListCellRenderer$UIResource
List.dropLineColor Color 99, 101, 111
List.focusCellHighlightBorder Border javax.swing.plaf.BorderUIResource$LineBorderUIResource
List.focusInputMap Input map javax.swing.plaf.InputMapUIResource
List.focusInputMap.RightToLeft Input map javax.swing.plaf.InputMapUIResource
List.font Font Dialog, 12.0
List.foreground Color 0, 0, 0
List.selectionBackground Color 0, 0, 0
List.selectionForeground Color 255, 247, 233
List.timeFactor Long 1000

Note: JList is shown above within a JScrollPane, as it is typically used. The first row is selected.

Special features

  • The UIDefaults "List.focusCellHighlightBorder" contains a border object that draws the pink keyboard focus outline around the focused list row.



  • When the list is disabled, the selected row still has a highlighted black background, but the foreground text reverts to the unselected black color. This creates black text on a black background, which makes the selected item unreadable (other look and feels don't have this problem). These colors can be overridden with setForeground( Color c ), setBackground( Color c ), setSelectionForeground( Color c ), and setSelectionBackground( Color c ).
  • When the list has the keyboard focus, it draws a pink outline around the selected item. There is no UIDefaults entry for this pink focus color, but the same color is available for other components, such as"CheckBox.focus" and "RadioButton.focus".
  • The list's margins crowd text along the left side of the list box. Space can be added by overriding the list's default cell renderer with setCellRenderer( ListCellRenderer r ).


Key Type Value
Menu.acceleratorFont Font Dialog, 12.0
Menu.acceleratorForeground Color 0, 0, 0
Menu.acceleratorSelectionForeground Color 0, 0, 0
Menu.arrowIcon Icon$MenuArrowIcon
Menu.background Color 174, 178, 195
Menu.border Border javax.swing.plaf.BorderUIResource$CompoundBorderUIResource
Menu.borderPainted Boolean false
Menu.crossMenuMnemonic Boolean true
Menu.font Font Dialog, 12.0
Menu.foreground Color 0, 0, 0
Menu.margin Insets 2, 2, 2, 2
Menu.menuPopupOffsetX Integer 0
Menu.menuPopupOffsetY Integer 0
Menu.selectionBackground Color 165, 165, 165
Menu.selectionForeground Color 0, 0, 0
Menu.shortcutKeys Array int
Menu.submenuPopupOffsetX Integer -2
Menu.submenuPopupOffsetY Integer 3

Note: JMenu is shown above within a JPopupMenu.

Special features

  • The normal menu arrow icon is available in the UIDefaults "Menu.arrowIcon".

    10 x 10
  • The UIDefaults "Menu.border" contains a border object that draws the recessed border around an armed menu.



  • There is no UIDefaults entry for the armed version of the menu arrow icon.
  • If any menu item on a menu has an icon, all of the menu items leave room for the icon (most look and feels do this). This can look odd if a menu item has an icon but no label. To avoid this look, always give menu items labels.


Key Type Value
MenuBar.background Color 174, 178, 195
MenuBar.border Border$MenuBarBorder
MenuBar.font Font Dialog, 12.0
MenuBar.foreground Color 0, 0, 0
MenuBar.highlight Color 220, 222, 229
MenuBar.shadow Color 99, 101, 111
MenuBar.windowBindings Array java.lang.Object

Special features

  • The UIDefaults "MenuBar.border" contains a border object that draws the normal beveled border around the menu bar.



  • Menu icons are cropped vertically to 22 pixels.


Key Type Value
MenuItem.acceleratorDelimiter String "+"
MenuItem.acceleratorFont Font Dialog, 12.0
MenuItem.acceleratorForeground Color 0, 0, 0
MenuItem.acceleratorSelectionForeground Color 0, 0, 0
MenuItem.arrowIcon Icon$MenuItemArrowIcon
MenuItem.background Color 174, 178, 195
MenuItem.border Border javax.swing.plaf.BorderUIResource$CompoundBorderUIResource
MenuItem.borderPainted Boolean false
MenuItem.font Font Dialog, 12.0
MenuItem.foreground Color 0, 0, 0
MenuItem.margin Insets 2, 2, 2, 2
MenuItem.selectionBackground Color 165, 165, 165
MenuItem.selectionForeground Color 0, 0, 0

Special features

  • The UIDefaults "MenuItem.border" contains a border object that draws the recessed border around an armed or selected menu item.



  • The UIDefaults "MenuItem.arrowIcon" is empty, but it isn't needed anyway (the icon is an implementation artifact).
  • If any menu item on a menu has an icon, all of the menu items leave room for the icon (most look and feels do this). This can look odd if a menu item has an icon but no label. To avoid this look, always give menu items labels.


Key Type Value
OptionPane.background Color 174, 178, 195
OptionPane.border Border javax.swing.plaf.BorderUIResource$EmptyBorderUIResource
OptionPane.buttonAreaBorder Border javax.swing.plaf.BorderUIResource$EmptyBorderUIResource
OptionPane.buttonClickThreshhold Integer 500
OptionPane.errorIcon Icon sun.swing.ImageIconUIResource
OptionPane.font Font Dialog, 12.0
OptionPane.foreground Color 0, 0, 0
OptionPane.informationIcon Icon sun.swing.ImageIconUIResource
OptionPane.messageAreaBorder Border javax.swing.plaf.BorderUIResource$EmptyBorderUIResource
OptionPane.messageForeground Color 0, 0, 0
OptionPane.minimumSize Dimension 262, 90
OptionPane.questionIcon Icon sun.swing.ImageIconUIResource
OptionPane.warningIcon Icon sun.swing.ImageIconUIResource
OptionPane.windowBindings Array java.lang.Object

Special features

  • The UIDefaults "OptionPane.errorIcon", et al contain the default icons for the corresponding option pane types. Unfortunately, they're ugly.

    18 x 18

    12 x 24

    24 x 24

    12 x 24


  • The option pane icons aren't all the same size. This will cause slightly different layouts for different option pane types.
  • The placement of buttons along the bottom of the panes is not consistent with native platform conventions. For the Mac, Windows, and Linux, dialog button conventions right-align all buttons instead of spreading them out. On the Mac, the "OK" button should be right-most, while for Windows the "OK" button should be left-most.


The CDE/Motif UIDefaults colors are available for download in the X11 rgb.txt file format:

Further reading

Related articles at

Web articles


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