Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4985801

1.4.2 Look and feel problems on Windows XP




         What's Wrong With The Windows XP Look And Feel

         This document describes problems with the appearance of Swing programs
         running on Windows XP. We tested using JDK 1.4.2_01.

         A number of problems were seen when using either the "High Contrast
         Black" or "High Contrast White" color schemes. You can configure your
         machine to use these schemes by doing the following:
            1. Open the Control Panel
            2. Open the Accessibility Options
            3. Click the Display page and check the Use High Contrast check box.
               Then click the Settings button. The "Settings for High Contrast"
               dialog will open; it contains a combobox that contains a number of
               preset color schemes, including "High Contrast Black" and "High
               Contrast White". Pick one and click the OK button to close the
               dialog, then click OK on the "Accessibility Options" dialog.

         System Colors

         The colors used in some Swing components are incorrect. Here's what we

            1. The color of JLabel should be SystemColor.windowText, not
               SystemColor.controlText. You can see this by changing the window
               text color using XP's "Display Properties" dialog ? make the text
               blue, and you'll see that JLabels still paint black text (black is
               the default control text color.)

            2. The color of disabled JLabels is incorrect. In the "High Contrast
               Black" color scheme, they are being drawn green instead of gray.

            3. The background color of a disabled JTextField is not the same as
               that of a JPasswordField. With the default XP color scheme, the
               default JTextField color is (235,235,228) while the disabled
               JPasswordField background color is (255,255,255). They should be
               the same.

            4. JTree expansion button border is drawn with the wrong color. It
               should be SystemColor.textInactiveText. You can see the difference
               by running XP in high contrast mode. Here's what a native tree
               looks like:

          (note the green button box)

         and here's what a JTree looks like: (note the gray box)

            5. The color of disabled menu items is incorrect. In high-contrast
               mode, you can easily see what's wrong.

         Here's what it should look like:
         And here's the Swing equivalent: (the text should NOT be green.)

            6. The text of disabled JRadioButtonMenuItem and JCheckBoxMenuItem is
               not painted correctly. In the "High Contrast Black" color scheme,
               the text is drawn in green (it should be gray), and the text does
               not have the white shadow which is present for disabled JMenuItem

            7. The color of the accelerator text for disabled JCheckBoxMenuItem
               is incorrect. In the "High Contrast Black" color scheme, the text
               is drawn black, making it unreadable against the black menu

         This is probably due to the use of the brigher and darker functions in
               BasicMenuItemUI.paintMenuItem in the code which paints the
               accelerator text. Using these functions will never yield correct
               results when using the High Contrast Black color scheme.

            8. Disabled JButton text is drawn with the wrong color in high
               contrast mode. The symptoms are the same as above ? the text is
               drawn in bright green instead of gray.

            9. The background area of scrollbars (i.e. the part between the
               buttons and the thumb) is not correct. This is obvious in
               high-contrast mode where the area is painted white, but should be

         Here's a native scrollbar:

         And here's the Swing equivalent:

            10. The color of the focus rectangle for JButtons is incorrect.
               This is obvious in the "High Contrast Black" scheme where the
               border is drawn solid white instead of dashed white.

            11. The color of the focus rectangle for JCheckBox and JRadioButton
               objects is incorrect. In the "High Contrast Black" color scheme,
               they're drawn in black instead of white.

            12. The border on the popup list for a JComboBox is hard-coded to
               be black in JDK 1.4.2. This makes it invisible in the "High
               Contrast Black" color scheme.

            13. The border on JScrollPane objects is always drawn black. This
               makes the border invisible in the "High Contrast Black" color
               scheme. (It's the wrong color).

            14. The color of titled borders is incorrect in JDK 1.4.2. In the
               "High Contrast Black" color scheme, the line is drawn
               black-on-black when it should use the window text color.

            15. The default background color of viewports should be that of the
               component it's displaying. This color is typically the Window
               color rather than ControlBackgroundColor (which is what JDK 1.4.2

            16. The cell focus border for JList is incorrect. In the "High
               Contrast White" color scheme, the focus border should be black,
               but it's drawn gray instead.

            17. JTree: The color of the lines between nodes and their children
               is incorrect. In "High Contrast Black", the lines should be green,
               but are drawn silver.

            18. JTree: The color of the "+/-" symbol in the expansion button is
               incorrect when using the "High Contrast Black" color scheme. The
               box is gray when it should be green, and the "+/-" symbol is black
               when it should be white.

            19. JTree: The color of the focus rectangle is incorrect. In "High
               Contrast Black", the rectangle is yellow when it should be green.

            20. The color of the tooltip border is incorrect. It appears to be
               hardcoded to black. You can see that it's wrong in the "High
               Contrast Black" color scheme.

         System Fonts

            1. When in high-contrast mode, the font face is not selected
               correctly for JLabels. It should be bold, but is not.

            2. When configured to use "Large Fonts" or "Extra Large Fonts", the
               default text size in a Swing program does not change. I think it

         Mnemonic Hiding

               Windows XP has an option to "hide underlined letters for keyboard
               navigation until I press the Alt key". This option is on by
               default. Here's how it works in a native Win32 application: For
               controls on a native dialog, the mnemonics are hidden until the
               ALT key is pressed. Once the key press happens, the mnemonics are
               draw, and stay drawn even after the ALT key is released.

               In Swing, the underline is removed once the ALT key is released,
               which is incorrect. This incorrect behavior is seen with
               JCheckBox, JButton, JRadioButton, and JLabel components.


            1. When a button has focus, it should be drawn with a colored border
               (blue by default, or orange if the mouse is hovering over the
               button). It should also have a dotted focus rectangle. This
               rectangle is missing from the XP look and feel.

         Here's an example of a native button with the focus:

            and at 200% magnification:

         and here is a JButton:
          and at 200% magnification:

         You may notice that the JButton is using a different font as well.


            1. The background color of the menu is incorrect.

         Here's what it should look like:

         and here's how it looks in SwingSet2


            1. Disabled scroll bars should draw their terminals (the arrow
               buttons) using the disabled control color. Currently, they are
               drawn normally.

         Here's the disabled scroll bar colors, as seen in the Windows Notepad

         and here they are in a sample which puts a JTextArea object on a

            2. The color of the arrow buttons on scroll bars is supposed to
               change when you click on them. The Swing scroll bars do not do
               this. In fact, native scroll bar buttons have 3 states, each with
               their own colors:

         Unpressed (no mouse):

         When the mouse is over the button:

         When the mouse button is pressed: (same as unpressed)

            3. The scrollbars on a scrollpane should not be in the tab order. For
               example, if a JList is on a JScrollPane, and you press the TAB key
               while the JList has focus, the focus moves to the JScrollBar. This
               is NOT the way native Windows applications behave.


            1. The table header height is too small.

         Compare the height of the header as seen in Windows Explorer window:

         to that of the table header in the TableExample3 program from JDK1.4.2:

            2. The table header does not have rollover colors

         Here's an example of a native header drawn with the rollover colors
               showing for the "Type" field.

            3. The row height does not change when the system font is set to a
               large font ? You can test this by configuring Windows to use
               "Extra Large Fonts".

            4. The text color is ControlText by default. This should be
               windowText. You can check this by setting the Windows Desktop's
               "WindowText" color to blue, then look at any table (e.g. in
               Windows Explorer).


            1. The selection color (the orange bar) is not shown when mousing
               over tabs. The orange highlight should be on the selected tab, and
               also on the tab under the mouse.

         You can see this by opening the "Display Properties" dialog (right-click
               on the Windows desktop and click the "Properties" menu item), then
               roll the mouse over the tabs (without clicking).

            2. The color of panels on a tab should be different from the usual
               dialog color. It should be the same as the selected-tab color.

         Here's an example of a native tabbed pane. The color of the tab and the
               page itself is a gradient. At the top the color is (252, 252,
               254); at the bottom it is (244,243,248).

         And here is a tabbed pane in the SwingSet2 sample. The panel color is a
               uniform (236,233,216).

            3. When the selected tab has focus (the focus rectangle is drawn on
               the tab text), and you press CTRL+DOWN, I believe this is supposed
               to select the first focusable component on the selected page. If
               the page's component is a JPanel which itself contains other
               components, the focus will be set to the JPanel. This is useless.
               The JPanel is NOT in the focus traversal cycle, so it makes no
               sense to give it the focus.

         This behavior appears to be caused by a poor implementation of
               BasicTabbedPaneUI.requestFocusForVisibleComponent, which does not
               check if the visible component is in the focus traversal cycle.

            4. Pressing CTRL+PAGEUP while a control on a JTabbedPane page has
               focus should select the next page and put focus to the first
               focusable component (which must be in the focus traversal cycle)
               on the newly selected page. Currently, pressing CTRL+PAGEUP does
               nothing unless the JTabbedPane itself has focus.

         Similarly, pressing CTRL+PAGEDOWN should select the previous page.
            1. The margin of the editor in a JComboBox is too small.

         Compare the width of white space to the left of the text from SwingSet2:
         and a the corresponding white space from Window' "Display Properties"

               The default margin is 0 pixels. It should have the same margin as
               a JTextField.


          Issue Links



              leifs Leif Samuelsson (Inactive)
              atongschsunw Albert Tong-schmidt (Inactive)
              0 Vote for this issue
              0 Start watching this issue