Results 1 to 6 of 6
  1. #1
    nik_meback is offline Member
    Join Date
    Dec 2010
    Posts
    19
    Rep Power
    0

    Default Listening to JPopupMenu invocation

    How can one listen to JPopupMenu invocation? I need to disable a JPopupmenu's JButton WHEN the JPopupMenu is invoked.

    Please note that I do not need to listen to a JPopupMenu's menu items, but to the popupmenu's invocation i.e. I need to execute some code WHEN the jpopupmenu is invoked.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,960
    Rep Power
    8

    Default

    This probably isn't perfect, but couldn't you add a MouseListener to the JPopupMenu?

    Or you could extend JPopupMenu to extend one of the methods that are invoked upon popup: setVisible maybe, or menuSelectionChanged, or show? Or use a SelectionModel?

    I'm just guessing, but those seem like solid places to start.
    Last edited by KevinWorkman; 12-01-2010 at 03:21 PM.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,237
    Rep Power
    19

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,960
    Rep Power
    8

    Default

    Quote Originally Posted by Darryl.Burke View Post
    How did I miss that? Weird, that Listener is not mentioned in the "How to Use Menus" tutorial. Hmph. You learn something new every day...

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,237
    Rep Power
    19

    Default

    Weird, that Listener is not mentioned in the "How to Use Menus" tutorial.
    Just as OverlayLayout isn't mentioned in the Layout tutorials.

    db

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,960
    Rep Power
    8

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Just as OverlayLayout isn't mentioned in the Layout tutorials.

    db
    :eek:

    I am learning much, oh wise one.

Similar Threads

  1. RMI Invocation
    By kavithakr in forum Advanced Java
    Replies: 1
    Last Post: 03-14-2009, 09:04 PM
  2. JPopupMenu
    By hungleon88 in forum NetBeans
    Replies: 8
    Last Post: 01-15-2009, 05:00 PM
  3. Invocation error in JMock
    By tanvij in forum New To Java
    Replies: 0
    Last Post: 05-14-2008, 09:05 AM
  4. HELP: Method Invocation
    By rjuyal in forum Advanced Java
    Replies: 4
    Last Post: 04-07-2008, 11:07 AM
  5. Replies: 2
    Last Post: 06-12-2007, 04:33 PM

Posting Permissions

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