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.