开发者

Making JPopupMenu's submenus heavyweight

开发者 https://www.devze.com 2023-01-30 01:47 出处:网络
http://java.sun.com/products/jfc/tsc/articles/mixing/index.html advices how to make JPopupMenus heavyweight. Just set the property:

http://java.sun.com/products/jfc/tsc/articles/mixing/index.html advices how to make JPopupMenus 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消