JMenu consumes focuslost event in Windows7 LAF Java7

▼魔方 西西 提交于 2019-12-01 11:36:57

Here is the magic line that fixes the problem:

UIManager.put("PopupMenu.consumeEventOnClose", Boolean.FALSE);

I found this after looking into the source code for the BasicPopupMenuUI class. Apparently this behaviour is a deliberate design choice according to the following comments in the code, but it sure feels like a bug to me.

            // Ask UIManager about should we consume event that closes
            // popup. This made to match native apps behaviour.

By the way, it happens in Java 5 and 6 too.

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