If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

problems wiith JMenu

I'm having problems with the ActionEvent on jMenuItems. I want that when you click on the menuitem, a form window opens. The problem with my code is that when you click for the first time it dosen't do anything, for the second time it does open the window. But, then if you click for a third time it opens two instances of the window, and so on.

1. It looks like the first time, you add the listener. Instead, add it during initialization.

2. The second click, the listener had been registered the first time and so the Form appears.

3. The third click. Well, everytime you click you create an new instance of object so you are gonna get a new window. If this is not desired, then use an instance variable and check it if is null, then create else show or whatever.