JMenu won’t 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 want 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.

Answer

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.

Leave a Reply

Your email address will not be published. Required fields are marked *