JPopupMenu display under Canvas

家住魔仙堡 提交于 2019-12-23 10:55:47

问题


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 ?


回答1:


JPopupMenu.setDefaultLightWeightPopupEnabled( false );

solved the issue.




回答2:


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



来源:https://stackoverflow.com/questions/9588524/jpopupmenu-display-under-canvas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!