Results 1 to 3 of 3
  1. #1
    alfredlok is offline Member
    Join Date
    Feb 2012
    Posts
    1
    Rep Power
    0

    Default 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:

    Java 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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default 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.

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

Similar Threads

  1. Replies: 4
    Last Post: 01-01-2012, 09:55 PM
  2. Java MouseClicked problem.
    By Love Like Rockets. in forum AWT / Swing
    Replies: 12
    Last Post: 10-30-2011, 01:58 PM
  3. typed events vs untyped events.
    By Drun in forum SWT / JFace
    Replies: 0
    Last Post: 11-23-2009, 12:22 PM
  4. MouseClicked Stop Animation
    By xpngamer in forum New To Java
    Replies: 1
    Last Post: 04-14-2009, 09:38 AM
  5. Menu item not working properly for mouse events
    By Preethi in forum New To Java
    Replies: 1
    Last Post: 09-23-2008, 08:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •