本文介绍了如何捕获窗口状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被打断了,想知道如何诱捕它吗?

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}

此处7minimizing的状态,而先前的状态是maximized.

here 7 is the state on minimizing when its previous state is maximized.

这篇关于如何捕获窗口状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 13:02