如何收听JCombobox选择事件



当我选择JCombobox时,当它被选中并显示下拉列表时,我想处理一个事件,当下拉列表消失并取消选择JCombobox时,我也要处理该事件。

注意,我不想听到项目选择的变化,而是当用户选择JCombobox并且UI弹出下拉菜单时。

您想要使用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);
}

相关内容

  • 没有找到相关文章

最新更新