JMenu fails to disappear when user clicks outside the JMenu................

I have implemented a JMenu within a JMenuBar everything runs fine. However, with this application and with all others I have seen when you click a JMenu leaving it open and then click anywhere on the title in Windows the JMenu remains open. Windows native programs dont do this and it is just a nuisance for a user to go and disable the JMenu by clicking it again.

Does anyone have a solution for this.

[422 byte] By [amarsyed] at [2007-9-26 4:09:36]
# 1

I'm using an IDE (VAJ 3.5.3) which actually implements JDK 1.2.2 and I have the same problem. This is definitly a Bug.

The JMenu pops up and can be closed by clicking anywhere in the application but not by clicking on the title bar (i.e of the JFrame). I think the attributes of the title bar are native-coded and the bar itself is created by the OS, respectively. If you use 100% JAVA, there is nothing you can do about it at the moment.

wagner99 at 2007-6-29 13:12:48 > top of Java-index,Archived Forums,Swing...
# 2
you could add a MouseListener to the JMenuand within mouseExited() method you can close the JMenu?hope this helps?
simon_orange at 2007-6-29 13:12:48 > top of Java-index,Archived Forums,Swing...
# 3

Hi Simon,

good Idea! But this produces some funny behaviour. If you add a MouseListener to the JMenu and override the mouseExited() method with something like getJMenu().setPopupMenuVisible(false);

the JMenu would close before you can select a JMenuItem :)

wagner99 at 2007-6-29 13:12:48 > top of Java-index,Archived Forums,Swing...
# 4
it was worth a go anyway.........
simon_orange at 2007-6-29 13:12:48 > top of Java-index,Archived Forums,Swing...
# 5
See the following bug entry: http://developer.java.sun.com/developer/bugParade/bugs/4488199.html
thomas_varga at 2007-6-29 13:12:48 > top of Java-index,Archived Forums,Swing...
# 6
Thx Thomas,there is no easy solution for this problem - as I suspected. Obviously, you have to get 1.4 and then make some workaround.
wagner99 at 2007-6-29 13:12:48 > top of Java-index,Archived Forums,Swing...
# 7
haven't tried it but could a FocusListener on the menu help? Close if Focus lost
arcosh at 2007-6-29 13:12:48 > top of Java-index,Archived Forums,Swing...
# 8

Hi Johannes,

I checked this and it did not work. Then I read the bug evaluation (should have done this before): JAVA doesn't get any event from the title bar. The workaround is provided in 1.4 with

"non-decorated window frames and the ability to add user defined window decorations".

I don't know this stuff. Is there anybody who already has got experience with these new features?

wagner99 at 2007-6-29 13:12:48 > top of Java-index,Archived Forums,Swing...
# 9

As this new feature works... say you have a JInternalFrame you want to be "modal" well cause they are lightweight, that is inpossible. SO now you can set a JDialog to unDecordated() and implement the JInternalFrame paint methods, and produce a "JInternalFrame" that is "modal" (just an example) i just the "setUndecorated(false);" in my JXcalendar popup, it works bette rthan JWindow, cause it listens for all window events.

> Hi Johannes,

>

> I checked this and it did not work. Then I read the

> bug evaluation (should have done this before): JAVA

> doesn't get any event from the title bar. The

> workaround is provided in 1.4 with

> "non-decorated window frames and the ability to add

> user defined window decorations".

> I don't know this stuff. Is there anybody who already

> has got experience with these new features?

haroldsmith at 2007-6-29 13:12:48 > top of Java-index,Archived Forums,Swing...