3
当我选择JCombobox
时,我希望处理选中的事件并显示下拉菜单,并在下拉菜单消失时处理事件并取消选择JCombobox
。如何收听JCombobox选择事件
请注意,我并不想要听选项选择更改,但用户选择JCombobox
时UI会弹出下拉菜单。
当我选择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);
}