How to trap the Window state? [closed]

孤街浪徒 提交于 2019-12-11 06:44:08

问题


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
    }
});

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.


回答1:


To check if a window was minimized use:

e.getNewState() == WindowEvent.WINDOW_ICONIFIED

For maximizing use: WindowEvent.WINDOW_DEICONIFIED

if(e.getNewState()==7){//your code goes here}

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



来源:https://stackoverflow.com/questions/8244172/how-to-trap-the-window-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!