[Java]
Package com. han;
Import java. awt. Frame;
Import java. awt. event. javaswevent;
Import java. awt. event. WindowStateListener;
Import javax. swing. JFrame;
/**
* Capture window status events
* @ Author HAN
*
*/
Public class extends wevent_2 extends JFrame {
/**
*
*/
Private static final long serialVersionUID =-2809729177140671167l;
Public parameter wevent_2 (){
// TODO Auto-generated constructor stub
AddWindowStateListener (new WindowStateListener (){
@ Override
Public void windowStateChanged (invalid wevent e ){
// TODO Auto-generated method stub
Int oldState = e. getOldState ();
Int newState = e. getNewState ();
String from = null;
String;
Switch (oldState ){
Case Frame. NORMAL:
From = "normalization ";
Break;
Case Frame. MAXIMIZED_BOTH:
From = "maximize ";
Break;
Case Frame. ICONIFIED:
From = "icon-based ";
Break;
} Www.2cto.com
Switch (newState ){
Case Frame. NORMAL:
To = "normalization ";
Break;
Case Frame. MAXIMIZED_BOTH:
To = "maximize ";
Break;
Default:
To = "icon-based ";
Break;
}
System. out. println (from + "---->" + );
}
});
}
/**
* @ Param args
*/
Public static void main (String [] args ){
// TODO Auto-generated method stub
Invalid wevent_2 frame = new vertex wevent_2 ();
Frame. setTitle ("Capture window status events ");
Frame. setVisible (true );
Frame. setdefaclocloseoperation (JFrame. EXIT_ON_CLOSE );
Frame. setBounds (0, 0,300,100 );
}
}
Author: Gaowen_HAN