public interface WindowListener
用于接收窗口事件的侦听器接口。旨在处理窗口事件的类要么实现此接口(及其包含的所有方法),要么扩展抽象类 WindowAdapter
(仅重写所需的方法)。然后使用窗口的 addWindowListener
方法将从该类所创建的侦听器对象向该 Window 注册。当通过打开、关闭、激活或停用、图标化或取消图标化而改变了窗口状态时,将调用该侦听器对象中的相关方法,并将 WindowEvent
传递给该方法。
WindowAdapter
,
WindowEvent
,
Tutorial: How to Write Window Listeners
方法摘要 | |
---|---|
void |
windowActivated(WindowEvent e) 将 Window 设置为活动 Window 时调用。 |
void |
windowClosed(WindowEvent e) 因对窗口调用 dispose 而将其关闭时调用。 |
void |
windowClosing(WindowEvent e) 用户试图从窗口的系统菜单中关闭窗口时调用。 |
void |
windowDeactivated(WindowEvent e) 当 Window 不再是活动 Window 时调用。 |
void |
windowDeiconified(WindowEvent e) 窗口从最小化状态变为正常状态时调用。 |
void |
windowIconified(WindowEvent e) 窗口从正常状态变为最小化状态时调用。 |
void |
windowOpened(WindowEvent e) 窗口首次变为可见时调用。 |
方法详细信息 |
---|
void windowOpened(WindowEvent e)
void windowClosing(WindowEvent e)
void windowClosed(WindowEvent e)
void windowIconified(WindowEvent e)
void windowDeiconified(WindowEvent e)
void windowActivated(WindowEvent e)
void windowDeactivated(WindowEvent e)