Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPopupMenu display under Canvas

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 ?

like image 862
Guillaume Massé Avatar asked Mar 06 '12 17:03

Guillaume Massé


2 Answers

JPopupMenu.setDefaultLightWeightPopupEnabled( false );

solved the issue.

like image 110
Guillaume Massé Avatar answered Nov 19 '22 21:11

Guillaume Massé


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

like image 31
mKorbel Avatar answered Nov 19 '22 22:11

mKorbel