3

当我选择JCombobox我想在它被选中并显示下拉列表时处理事件以及在下拉列表消失并且JCombobox取消选择时处理事件。

请注意,我不是在寻找项目选择更改,而是在用户选择JCombobox并且 UI 弹出下拉菜单时。

4

1 回答 1

8

您想使用addPopupMenuListener,它使用以下接口:

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);
}
于 2012-08-22T20:12:09.000 回答