Making JPopupMenu's submenus heavyweight
http://java.sun.com/products/jfc/tsc/articles/mixing/index.html advices how to make JPopupMenu
s heavyweight. Just set the property:
setLightWeightPopupEnabled(false);
It works fine, but if I have submenus in the popup, implemented as JMenu
items, they开发者_运维百科 don't seem to inherit the popup's heavy weight. JMenu
doesn't have a method to make itself heavyweight, and using an AWT Menu
isn't an option, since I want to put Swing items into it.
How do I make the submenus heavyweight, too?
It seems to be a Swing bug. Setting the global property
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
works! Also submenu JMenu
items go heavy, as they should. Obviously the per-instance method setLightWeightPopupEnabled
should work similarly, but it doesn't.
I filed a bug (Bug Id: 7005406) on this, but I leave the question here just in case that someone else bumps on this. So the solution is to use the global setting until the bug gets fixed.
精彩评论