Java captures other window events

Source: Internet
Author: User



[Java]
Package com. han;
 
Import java. awt. event. javaswevent;
Import java. awt. event. WindowListener;
 
Import javax. swing. JFrame;
 
/**
* Capture other window events
* @ Author HAN
*
*/
Public class extends wevent_3 extends JFrame {
 
/**
*
*/
Private static final long serialVersionUID = 9040264048222645786L;
 
Public vertex wevent_3 (){
// TODO Auto-generated constructor stub
AddWindowListener (new WindowListener (){
 
@ Override
Public void windowOpened (invalid wevent e ){
// TODO Auto-generated method stub
System. out. println ("window opened! ");
}
 
@ Override
Public void windowClosing (WindowEvent e ){
// TODO Auto-generated method stub
System. out. println ("the window will be closed! ");
}
 
@ Override
Public void windowClosed (WindowEvent e ){
// TODO Auto-generated method stub
System. out. println ("the window has been closed! ");
}
 
@ Override
Public void incluwiconified (incluwevent e ){
// TODO Auto-generated method stub
System. out. println ("window icons! ");
}
 
@ Override
Public void windowDeiconified (invalid wevent e ){
// TODO Auto-generated method stub
System. out. println ("the window is not marked! ");
}
 
@ Override
Public void windowActivated (WindowEvent e ){
// TODO Auto-generated method stub
System. out. println ("window activated! ");
}
 
@ Override
Public void windowDeactivated (invalid wevent e ){
// TODO Auto-generated method stub
System. out. println ("the window is no longer active! ");
}

});
}
 
/**
* @ Param args
*/
Public static void main (String [] args ){
// TODO Auto-generated method stub
WindowEvent_3 frame = new WindowEvent_3 ();
Frame. setTitle ("capture other window events ");
Frame. setVisible (true );
Frame. setdefaclocloseoperation (JFrame. DISPOSE_ON_CLOSE );
Frame. setBounds (0, 0,300,100 );
}
 
}
Author: Gaowen_HAN

Related Article

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.