3

When I select the JCombobox I want to handle an event when its selected and the dropdown is shown as well as handle the event when the drop down disappears and the JCombobox is de-selected.

Note, i'm not looking to listen for an item selection change but for when the user selects the JCombobox and the UI pops out the Dropdown.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Sammy Guergachi
  • 1,986
  • 4
  • 26
  • 52

1 Answers1

8

You want to use addPopupMenuListener which uses the following interface:

public interface PopupMenuListener extends EventListener {

    /**
     *  This method is called before the popup menu becomes visible 
     */
    void popupMenuWillBecomeVisible(PopupMenuEvent e);

    /**
     * This method is called before the popup menu becomes invisible
     * Note that a JPopupMenu can become invisible any time 
     */
    void popupMenuWillBecomeInvisible(PopupMenuEvent e);

    /**
     * This method is called when the popup menu is canceled
     */
    void popupMenuCanceled(PopupMenuEvent e);
}
Reverend Gonzo
  • 39,701
  • 6
  • 59
  • 77