JPopupMenu display under Canvas
Asked Answered
B

2

6

I have a Canvas, some text fields and a context menu.

When I start the application and right click on the canvas a popup menu shows. But when I write something inside the text field than I right click on the canvas, the popup will shows behind the canvas.

Any idea how to fix that ?

Boor answered 6/3, 2012 at 17:13 Comment(2)
put up some code, ideally an SSCE. Usually, just by writing an SSCE you will find your issue.Motteo
sscce.org, sorry I missed a CMotteo
B
6
JPopupMenu.setDefaultLightWeightPopupEnabled( false );

solved the issue.

Boor answered 6/3, 2012 at 20:8 Comment(1)
This call affects all popup menus that will be created in future. Usually it is enough to modify lightWeightPopupEnabled property of the particular JPopup instance by calling popup.setLightWeightPopupEnabled(false).Calibrate
S
3

1) Canvas is AWT Component, and is Heavyweight type of Components

2) JPopupMenu is Swing JComponent and is Lightweight type of JComponents

3) possible to solve that by using Swing JPanel rather than AWT Canvas

4) your issue is about Mixing Heavyweight and Lightweight Components or rest is here

Stochmal answered 6/3, 2012 at 17:24 Comment(4)
I need a Heavyweight component to draw into it with opengl.Cernuous
agreed correct way for OpenGL, your choice is more simpler than use JPopup use Window or un_decorated Dialog, there you can put Swing JButtons, for laying use GridLayoutStochmal
Uggh.. adding replies before I've had my coffee is pointless. +1Fescue
@Andrew Thompson maybe your insomnia :-)Stochmal

© 2022 - 2024 — McMap. All rights reserved.