有3个Frame,Frame上面没有任何组件,
A窗口是当前窗口时,如果按‘esc’,就退出整个JAVA VM
B窗口是当前窗口时,如果按‘esc’,就退出B,而不退出整个JAVA VM
C窗口是当前窗口时,如果按‘esc’,就退出C,而不退出整个JAVA VM这应该如何实现?加载顺序必须是先A,再B,再C,我用过KeyEventPostProcessor这个接口,即使是B窗口为当前激活窗口,一按‘ESC’就全部退出了;如果用dispose(),那么A窗口为当前窗口时也就单独退出,无法实现全部退出
有什么好的解决方案吗?
A窗口是当前窗口时,如果按‘esc’,就退出整个JAVA VM
B窗口是当前窗口时,如果按‘esc’,就退出B,而不退出整个JAVA VM
C窗口是当前窗口时,如果按‘esc’,就退出C,而不退出整个JAVA VM这应该如何实现?加载顺序必须是先A,再B,再C,我用过KeyEventPostProcessor这个接口,即使是B窗口为当前激活窗口,一按‘ESC’就全部退出了;如果用dispose(),那么A窗口为当前窗口时也就单独退出,无法实现全部退出
有什么好的解决方案吗?
按照你的描述应该是一个模式话对话框啊
说白了,是要监听键盘动作,否则实现不了的,但我不知道键盘监听有多少种方法,怎么用
void windowActivated(WindowEvent e)
Invoked when the Window is set to be the active Window.
void windowClosed(WindowEvent e)
Invoked when a window has been closed as the result of calling dispose on the window.
void windowClosing(WindowEvent e)
Invoked when the user attempts to close the window from the window's system menu.
void windowDeactivated(WindowEvent e)
Invoked when a Window is no longer the active Window.
void windowDeiconified(WindowEvent e)
Invoked when a window is changed from a minimized to a normal state.
void windowIconified(WindowEvent e)
Invoked when a window is changed from a normal to a minimized state.
void windowOpened(WindowEvent e)
Invoked the first time a window is made visible覆盖你要的方法就行了,windowClosing或windowClosed都可以
System.exit(0);
B窗口是当前窗口时
B.setVisiable(false);
B.setEnable(false);
C窗口是当前窗口时
C.setVisiable(false);
C.setEnable(false);