JPopupMenu display under Canvas

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

When I launch the application and right-click on the canvas, a popup menu appears. But when I write something inside the text box, I just click on the canvas, a popup will be shown behind the canvas.

Any idea how to fix this?

+5
source share
2 answers
JPopupMenu.setDefaultLightWeightPopupEnabled( false );

solved a problem.

+5
source

1) Canvasis AWT ComponentandHeavyweight type of Components

2) JPopupMenu- Swing JComponentandLightweight type of JComponents

3) you can solve this by using Swing JPanel, rather thanAWT Canvas

4) your problem is related to mixing heavy and light components or rest here

+3
source

All Articles