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 ?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Guillaume Massé
  • 8,004
  • 8
  • 44
  • 57

2 Answers2

6
JPopupMenu.setDefaultLightWeightPopupEnabled( false );

solved the issue.

Guillaume Massé
  • 8,004
  • 8
  • 44
  • 57
  • 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)`. – Petr Mar 16 '18 at 08:26
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

Petr
  • 108
  • 1
  • 6
mKorbel
  • 109,525
  • 20
  • 134
  • 319