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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With