8

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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Joonas Pulakka
  • 36,252
  • 29
  • 106
  • 169
  • +1 nice one, this saved me time. – KJW Nov 30 '11 at 10:02
  • Dude, it seems your update is a perfectly valid answer to your question, so move the update to answer, and mark the answer as accepted, it will make the internet (and more especially Stackoverflow) a little better. – Riduidel Oct 09 '12 at 13:00

1 Answers1

5

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.

Joonas Pulakka
  • 36,252
  • 29
  • 106
  • 169