当我选择JCombobox
时我想要处理一个事件,当它被选中并显示下拉列表时,以及当下拉消失并取消选择JCombobox
时处理事件。 / p>
注意,我不打算听取项目选择更改,但是当用户选择JCombobox
并且UI弹出下拉列表时。
答案 0 :(得分: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);
}