Wednesday, November 17, 2010

Develop a Java application to demonstrate the use WindowEvent class


/* Program : 21 
   Develop a Java application to demonstrate the use WindowEvent class  
   Developed by : Malhar Vora
   Developed on : 5-11-2010
   Development Status : Completed and tested
   Email     : vbmade2000@gmail.com
   WebSite   : http://technojungle.co.cc
*******************************************************************************************************************/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;


public class P21 extends JFrame implements WindowListener
{
 
  JLabel lblStatus=null;
 
  P21()
  {
   
   lblStatus = new JLabel("Message will be printed here");
   
   setSize(400,500);
   setVisible(true);
   setLayout(null);
   setDefaultCloseOperation(EXIT_ON_CLOSE);
   
   lblStatus.setBounds(50,50,200,50);
   this.getContentPane().add(lblStatus);
   
   addWindowListener(this);
  }
  
  public void windowActivated(WindowEvent we)
  {
   lblStatus.setText("Window Activated");
  }
  
  public void windowDeactivated(WindowEvent we)
  {
   lblStatus.setText("Window Deactivated");
  }
  
  public void windowOpened(WindowEvent we)
  {
   lblStatus.setText("Window Opened");
  }
  
  public void windowClosed(WindowEvent we)
  {
   lblStatus.setText("Window Closed");
  }
  
  public void windowIconified(WindowEvent we)
  {
   lblStatus.setText("Window Iconified");
  }
  
  public void windowDeiconified(WindowEvent we)
  {
   lblStatus.setText("Window Deiconified");
  }
  
  public void windowClosing(WindowEvent we)
  {
   lblStatus.setText("Window Closing");
  }
  public static void main(String []str)
  {
   P21 p = new P21();
  }
   
}

No comments:

Post a Comment