I've added a JMenu to an undecorated JFrame and the JMenuItem is not painted until I move the mouse over the unpainted area. Has anyone seen this problem and know how to fix/circumvent? Here is a reduced test case showing the problem.
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class TestCase {
public static void main(String[] args) throws Exception {
new JFrame() {{
setJMenuBar(new JMenuBar() {{
setOpaque(true);
add(new JMenu("ProblemMenu") {{
setOpaque(true);
add(new JMenuItem("NotPainted"){{
setOpaque(true);
}});}});}});
setUndecorated(true);
setBackground(new Color(11,111,222,196));
setSize(300,300);
setLocation(300,300);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(new JButton(" OpaqueButton "));
setVisible(true);
}};
}
}
Click the menu "ProblemMenu" and the menu will open with a white rectangle where the JMenuItem should be located. Move the mouse over that area and the JMenuItem paints.