Java capture window status events

Source: Internet
Author: User


[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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.