Menu Events actionPerformed vs mouseClicked
I am very new in Java.
I am using Netbeans.
Using the Netbeans, I create a form, say Myform1, adding a Menubar and a button *myButton". There are 2 menus in the menubar - menuFile and menuEdit. Using the GUI, I add event to the menuFile. The response is to:
Code:
JOptionPane.showMessageDialog( this.getParent(), "Yes", "No", 1);
First test: menuFile: add an actionPerformed.
When I click the menuFile, there is no response. I notice that the menu file's appearance is "inverse" (ie. background is turned dark), but no Dialog box.
Second Test: menuFile: add a MouseClicked
Same code.
The Message Dialog displays correctly.
Third Test: myButton: add an actionPerformed
Same code.
The Message Dialog displays correctly.
I am confused. Why menuitem does not response to actionPerformed? But a button can?
Thanks.
Alfred
Re: Menu Events actionPerformed vs mouseClicked
Much depends on the program's code, something we can't see, and to further obfuscate things, there's the issue that this code is mostly complex, large and often confusing NetBean's generated code. This will greatly limit our ability to help you. For this and many other reasons, I strongly urge newbies to Swing to not have NetBeans generate your Swing code, but rather that you study the Swing tutorials and learn to first do it by hand.
Re: Menu Events actionPerformed vs mouseClicked