Using a JMenu as a real option
I'm setting up a menu where I have an "exit" menu on the right of the JMenuBar.
I already tried to use a JMenuItem instead of a JMenu to do the job, but the L&F of the menu is different from a JMenu (the vertical gradient isn't draw) and I can't control its width.
If I use a JMenu without any JMenuItems associated, the menu is selected when I click it and doesn't work properly.
The most aproximate result that I was able to come up was using a JMenu for the purpose and on the selected event I change the "selected" property of the menu (with the setSelected method) to false. Unfortunately, if the user cancels the Exit option (on a confirmation dialog that pops up) I can see the "remains" of the JPopupMenu (which is empty) and if I click again on the menu, aside from the fact that the "selected" event isn't fired, the menu is selected.
So, how would you solve this issue? How can I make an EXIT menu which allows the user to terminate the application by clicking an option on the first level of a JMenuBar?