Yunithium
Yunithium

Reputation: 71

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.

Upvotes: 2

Views: 876

Answers (2)

Yunithium
Yunithium

Reputation: 71

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.

Upvotes: 3

camickr
camickr

Reputation: 324118

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.

Upvotes: 2

Related Questions