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.
精彩评论