问题描述
我被打断了,想知道如何诱捕它吗?
I'd a snipped and want to know how to trap it?
frame.addWindowStateListener(new WindowStateListener(){
public void windowStateChanged(WindowEvent e) {
System.out.println(e.getNewState());//I need to trap this state when it prints 7
}
});
当显示帧实例时,在maximizing
之后,然后单击minimize
按钮,它会打印7
(窗口状态).我需要陷入那种状态.有人能告诉我该怎么做吗?
我已经知道e.getNewState()
将返回7
,但是我想要此状态的名称.
When the instance of frame is visible then after maximizing
and then clicking on minimize
button it prints 7
(the state of window). I need to trap that state. Can any body tell me how to do so?
I already know that the e.getNewState()
will return 7
but I want the name of this state.
推荐答案
要检查窗口是否已最小化,请使用:
To check if a window was minimized use:
e.getNewState() == WindowEvent.WINDOW_ICONIFIED
为了最大限度地利用:WindowEvent.WINDOW_DEICONIFIED
For maximizing use: WindowEvent.WINDOW_DEICONIFIED
if(e.getNewState()==7){//your code goes here}
此处7
是minimizing
的状态,而先前的状态是maximized
.
here 7
is the state on minimizing
when its previous state is maximized
.
这篇关于如何捕获窗口状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!