JDK-8041731 : JPopupMenu items invisible on heavyweight popups on translucent windows
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u45,7-pool
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows
  • Submitted: 2013-12-03
  • Updated: 2014-11-21
  • Resolved: 2014-05-23
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
If a menu is using heavyweight popups (e.g., by setLightWeightPopupEnabled(false);) and that menu is opened from a translucent window, the menu items are invisible. The menu itself appears, but it is blank until the items are redrawn by rolling the mouse over them one by one.

Although lightweight popups are on by default, this bug also occurs if the menu popup does not fit within the bounds of the parent window, because then it has no choice but to use a heavyweight popup. There is definitely something odd going on. Please run the attached test case for a demonstration.

This bug occurs on all look-and-feels.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class Test1 {
public static void main(final String[] args) {
if (!EventQueue.isDispatchThread()) {
EventQueue.invokeLater(new Runnable() {
public void run() {
main(args);
}
});
return;
}

final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

JMenuBar menuBar = new JMenuBar();
final JMenu file = new JMenu("File");
menuBar.add(file);
final JCheckBoxMenuItem enableTransparency = new JCheckBoxMenuItem("Enable transparency");
final JCheckBoxMenuItem enableLWPopup = new JCheckBoxMenuItem("Enable light-weight popup");
file.add(enableTransparency);
file.add(enableLWPopup);
file.addSeparator();
file.add(new JMenuItem("New"));
file.add(new JMenuItem("Open"));
file.add(new JMenuItem("Save"));
file.add(new JMenuItem("Exit"));

enableLWPopup.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
file.getPopupMenu().setLightWeightPopupEnabled(
enableLWPopup.isSelected());
}
});

enableTransparency.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
if (enableTransparency.isSelected()) {
frame.setUndecorated(true);
frame.setBackground(new Color(0, 0, 255, 40));
} else {
frame.setBackground(null);
frame.setUndecorated(false);
}
frame.setVisible(true);
}
});

file.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
enableLWPopup.setSelected(file.getPopupMenu().isLightWeightPopupEnabled());
enableTransparency.setSelected(!frame.isOpaque());
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
public void popupMenuCanceled(PopupMenuEvent e) {}
});

frame.setJMenuBar(menuBar);

frame.setPreferredSize(new Dimension(300, 200));

frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
Comments
Closing this bug as a duplicate of JDK-7160604.
23-05-2014

It was defined that this bug existed in JDK 8, but in JDK 1.8.0-b119 it was resolved by the fix for the similar bug JDK-7160604. It was practically proven that porting of the fix for JDK-7160604 bug to JDK 7 resolves this bug, thus this bug is a duplicate of JDK-7160604 bug.
23-05-2014

The bug was reproduced with JDK 7u55 b13, but it could not be reproduced with JDK 9 b09, JDK 8u5 b13.
24-04-2014