JDK-4551985 : Background color of Menu is different from that of MenuBar
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.1_01,1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2001-12-06
  • Updated: 2003-02-04
  • Resolved: 2002-11-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
1.3.1_07 07Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
A licensee found out diffrent view of application between Windows2000 
and WindowsXP.

With Windows2000(or older windows), Menu and Menubar have the same background
However, winth WindowsXP, the background color of Menu is different from
that of MenuBar.

Please see the attached JPEG file(diff-color.JPG).

1. Reproduce

 1) Compile the attached sample program(SampleMenu.java) 
 2) Invoke the Sample program

2. Configration

 MPU: Pentium IV 1.4[GHz]
 Mem: 384[MB]
 OS : WindowsXP(japanese)
 JDK: 1.3.1_01a, 1.4.0-rc-b88

  The licensee's environment:    
    MPU: Pentium II 447[MHz]
    Mem: 288[MB]
    OS : WindowsXP(japanese)
    JDK: 1.3.1_01a

3. Note
 - Licensee point out as follows.
    - This happnes to most of application which use java.awt.MenuBar class.
    - This is caused by the different way how to draw each compoments.
      The java.awt.MenuBar uses DrawMenuBar of Win32 API. 
      The java.awt.MenuItem uses GetSysColor to get COLOR_MENU value,
      and java.awt.Menu does also because it is the subclass of MenuItem class.
      In other word, Menu and MenuItem class will be drawn by same color.
      MenuBar has possibility to be drawn by different color.
 - Please see the "workaround" also.



Name: jk109818			Date: 08/23/2002

java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

Microsoft Windows XP [Version 5.1.2600]

Very standard XP configurations (tested on XP Professional
and XP Home Editions)

Using Windows Look and Feel, the background color of the
Swing menubar and menu items is white on a standard XP
configuration.  This white color does not match the
background color of the toolbars (which is beige or
something), but it should. It is inconsistent with other
Windows apps.

Apparently the JToolbar is getting the right color, so the
menubar and menu items must not be using the correct
system property.

I tried changing the Windows "Display
Properties", "Appearance", "Advanced Appearance", altering
the "Menu" color setting (which was white, to beige), and
that did make the menus appear right, but a user shouldn't
have to do that to make the application have the same
appearance as all of the other Windows applications.  (I
don't know why the other standard Windows apps don't pay
attention to this "Menu" color setting, or why the default
is white.)

This default white background color has one other bad
effect.  When the mouse moves over a menu item with a pull-
right/cascade submenu, the right-arrow/triangle indicator
turns white, and disappears into the background!

1. Run the SwingSet2 demo from the J2SDK1.4.0 installation.
2. Look at the color of the menubar and menus, compared to
the color of the JToolbars.  They should match (both being
beige, I guess).

I expected the menubar and menu to have normal "Windows"
background colors, but they were white.

This bug can be reproduced always.

(Review ID: 146979)

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3.1_07 1.4.0_04 1.4.1_03 mantis FIXED IN: 1.3.1_07 1.4.0_04 1.4.1_03 mantis INTEGRATED IN: 1.3.1_07 1.4.0_04 1.4.1_03 mantis mantis-b08

EVALUATION ###@###.### 2002-08-06 This is not a bug. Because by default on WinXP the menu & menubar colour are different. Menu has white on WinXP. To change this, Settings -> Control Panel -> Display -> Appearance Select Menu from the Item list and see the colour. Change this on WinXP to the same colour as MenuBar The J2SE code uses the variable COLOR_MENU (awt_MenuItem.cpp) to get the menu colour if it is not selected. This corresponds to the same colour as in what is set through the control panel. This is not a bug. Will close this bug once the customer okays my findings. ###@###.### 2002-08-14 There is a difference in WinNT and WinXP. Behaviour on WinNT ------------------ If you change the Menu color using Control Panel, the entire menubar of all applications open and any new applications which comes up has this color. Also the dropdown menu for each of the menu items also changes to the color. The menubar of Control Panel, Windows explorer all change to the selected colour. With the testcase, the entire menubar changes to the selected color. Behaviour on WinXP ------------------ If you change the Menu color using Control Panel, for the windows applications, like Control Panel, Windows explorer, the menubar is still grey but only the dropdown menu changes to the selected color. But the testcase comes up with just the MenuItems changed to the selected colour and the remaining menubar remains grey. I am not sure which is a bug here. Is it XP or our java application ? ###@###.### 2002-08-23 In XP there is a variable COLOR_MENUBAR which controls the colour of the menubar. Since our binaries are being built on WinNT, this variable is defined in winuser.h which comes with the latest Visual Studio.NET, I will have to find a nice way of fixing it. ###@###.### 2002-11-20 The fix as mentioned in Suggested fix is not complete. It only works for 'Windows XP Style' (Control Panel->Display) 'Windows Classic Style' still shows different colours in the menubar. A bug has been filed (4781104) against 'Windows Classic Style'

WORK AROUND Setting environment to displaying with "classic style". Although I do not know well what word is used on each menu or tag with WindowsXP(english), I will show how to set with XP(Japanese) as sample. - Select [Control Panel]-[System]-[setting]-[performance] - Click the radio button of "prioritize performance" (I do not know if the above word is correct or not.) Then, windows design changes like windows2K and older(win98/Me/NT). 2001-12-06 =============================================================================

SUGGESTED FIX ###@###.### 2002-09-20 Files which were changed for the fix j2se/src/win32/native/sun/windows/awt.h j2se/src/win32/native/sun/windows/awt_MenuItem.cpp $ sccs diffs -C awt.h ------- awt.h ------- *** /tmp/sccs.qpaG9R Fri Sep 20 20:49:56 2002 --- awt.h Mon Sep 9 15:34:15 2002 *************** *** 101,106 **** --- 101,107 ---- #endif #define IS_NT (IS_WIN32 && !(::GetVersion() & 0x80000000)) #define IS_WIN2000 (IS_NT && LOBYTE(LOWORD(::GetVersion())) >= 5) + #define IS_WINXP (IS_WIN2000 && HIBYTE(LOWORD(::GetVersion())) >= 1) #define IS_WIN32S (IS_WIN32 && !IS_NT && LOBYTE(LOWORD(::GetVersion())) < 4) #define IS_WIN95 (IS_WIN32 && !IS_NT && LOBYTE(LOWORD(::GetVersion())) >= 4) #define IS_WIN98 (IS_WIN95 && HIBYTE(LOWORD(::GetVersion())) >= 10) $ sccs diffs -C awt_MenuItem.cpp ------- awt_MenuItem.cpp ------- *** /tmp/sccs.Pvaa.R Fri Sep 20 20:50:17 2002 --- awt_MenuItem.cpp Wed Sep 18 17:25:47 2002 *************** *** 216,223 **** // Disabled text must be drawn in gray. crText = ::GetSysColor(bEnabled? COLOR_HIGHLIGHTTEXT : COLOR_GRAYTEXT); } else { // Set background and text colors for unselected item ! crBack = ::GetSysColor (COLOR_MENU); // Disabled text must be drawn in gray. crText = ::GetSysColor (bEnabled ? COLOR_MENUTEXT : COLOR_GRAYTEXT); } --- 216,236 ---- // Disabled text must be drawn in gray. crText = ::GetSysColor(bEnabled? COLOR_HIGHLIGHTTEXT : COLOR_GRAYTEXT); } else { + + // COLOR_MENUBAR is only defined for Windows XP. Our binaries + // are built on NT and hence the below ifdef's + + #ifndef COLOR_MENUBAR + #define COLOR_MENUBAR 30 + #endif + // Set background and text colors for unselected item ! if (IS_WINXP && IsTopMenu()) { ! crBack = ::GetSysColor (COLOR_MENUBAR); ! } else { ! crBack = ::GetSysColor (COLOR_MENU); ! } ! // Disabled text must be drawn in gray. crText = ::GetSysColor (bEnabled ? COLOR_MENUTEXT : COLOR_GRAYTEXT); }