开发者

JMenu won't close when clicking elsewhere

开发者 https://www.devze.com 2023-03-24 02:54 出处:网络
I\'m trying to make a swing gui but currently experiencing trouble with making JMenus \"close\" when clicking elsewhere.

I'm trying to make a swing gui but currently experiencing trouble with making JMenus "close" when clicking elsewhere. If a JMenu is selected/open i wan开发者_C百科t it to close when clicking somewhere else on the gui but instead it remains open (most of the time) and the only way for me to close it is to click on the selected JMenu again.

I've searched for a solution but only seem to find bug reports on this matter. Any help is appreciated, thanks.


Ok i found the problem last night. One of the ActionListeners for the JMenuItems had an initializer for a JDialog in the contructor, i found it when i was trying to recreate the problem. Thanks for replying.


I have never seen this problem.

Read the section from the Swing tutorial on How to Use Menus for working examples.

Compare your code to the working code to see what is different.

If you still can't find the problem then post your SSCCE that demonstrates the problem because there is no way we can guess what you are doing different from the working examples.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号