JDK-6824644 : Selected JMenu not painted properly in Vista L&F if menu is lightweight
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u12
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2009-04-01
  • Updated: 2011-02-16
  • Resolved: 2010-06-28
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6001]

A DESCRIPTION OF THE PROBLEM :
The selection of a JMenu in another JMenu is not painted properly if the JMenu is fold out and an arbitrary item of the embedded JMenu is selected. This problem does only occur with Windows (Vista) L&F and lightweight JMenus. A small part of the selection is painted above the embedded JMenu (see "Error" menu item in provided test case)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
This issue can be reproduced with every Swing based application that uses the Windows L&F on Vista and has JMenus embedded into other JMenus.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected painting of the menus should look equal to native Vista applications.
ACTUAL -
A small part of the selection of the JMenu (at the right or the left, depending on where the embedded JMenu is fold out) is painted above the embedded JMenu.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class Test extends JFrame {

	public Test() {

		//JPopupMenu.setDefaultLightWeightPopupEnabled(false);

		JMenuBar mb = new JMenuBar();
		JMenu m1 = new JMenu("Test");
		m1.add(new JMenuItem("Test"));
		m1.add(new JMenuItem("Test"));

		JMenu m2 = new JMenu("Error");
		m2.add(new JMenuItem("Test"));
		m2.add(new JMenuItem("Test"));
		m2.add(new JMenuItem("Test"));

		m1.add(m2);
		mb.add(m1);

		setJMenuBar(mb);

		setSize(200, 200);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
	}

	public static void main(String[] args) throws Exception {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				new Test();
			}
		});
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
make popups heavyweight