glCanvas cutting Menubar Dropwindow (Screenshot included)

The problem is simple, the solution unknown…

My glCanvas(Inside is a jME Szene) is cutting off my Dropwindow.

The menubar should be in the foreground! Exist there any Solution?



Screenshot:


This is because you are mixing lightweight and heavyweight swing components. The canvas is heavyweight and therefore the painting is controlled natively (by your OS). You menu is a lightweight component drawn by swing.



The solution is to tell swing to use a heavyweight component in place of the lightweight one for your menu popup.


menu.setLightWeightPopupEnabled(false);

Thanks!!! Worked!

Thought something like that, but I would have tried to repaint it every time(without success of course^^)

I had the same problem, but menu.setLightWeightPopupEnabled(false); did not solve my problem becose sometimes it was slow. Menu apears first like gray rectangle and menuItems are painted after a while…



I found this solution that works much better. I is static function that need to be called once on application initialization.




public static void heavyWeightWorkaround()
{
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
try {
// Due to the strange way PopupFactory is implemented, we need to
// use reflection to make sure
// we *really* get heavyweight popups from the very start.
Class popup = PopupFactory.class;
Field heavyweight = popup.getDeclaredField("HEAVY_WEIGHT_POPUP");
Method setPopupType =
popup.getDeclaredMethod("setPopupType", Integer.TYPE);
heavyweight.setAccessible(true);
setPopupType.setAccessible(true);
setPopupType.invoke(PopupFactory.getSharedInstance(), heavyweight
.get(null));
}
catch (Exception ex) {
System.out.println("EXCEPTION");
}
}



Btw, I found this in source code of ArtOfIllusion (  http://www.artofillusion.org/ )