How to get focus in JPopupMenu

泪湿孤枕 提交于 2019-12-05 06:36:57

Once you do jpopupMenu.show(Component invoker, int x, int y)it will automatically respond to keyboard as you want. If this is not working then you might need to fix some other issue i.e some other component is snatching away focus from the menu when it should not etc.

Instead of KeyListener, I'd recommend adding Action instances to your JPopupMenu. Use setComponentPopupMenu() to add the popup to your panel.

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