WindowEvent

Advertisements

Prev Tutorial Next Tutorial

Event Handling for Window

Event handling for window you need WindowEvent and WindowListener interface.

Event classListener Interface
WindowEventWindowListener

Method (abstract method)

public void windowOpened(WindowEvent e): This method will be execute if the window is open.

public void windowClosing(WindowEvent e): This method will be execute if the window is going to be closed.

public void windowClosed(WindowEvent e): This method will be execute if the window is already closed.

public void windowActivate(WindowEvent e): This method will be execute if the window is in selected state.

public void windowDeactivated(WindowEvent e): This method will be execute if the window is not in selected state.

Example of ItemEvent

import java.awt.*;
import java.awt.event.*;

class A extends Frame 
{
A()
{
setTitle("Insurance Managment Sysytem");
setBackground(Color.cyan);
setLayout(null);
   
 addWindowListener(new WindowAdapter()
{
  public void windowClosing(WindowEvent we)
{
  System.exit(0);
  }
  });

setSize(500,300);
setVisible(true);
}  //constructor
}  // class

class WindowEventEx
{
public static void main(String s[])
{
A obj=new A();
}
}	

Download code Click

window close example
Prev Tutorial Next Tutorial

Advertisements

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Download Projects

Advertisements


Buy Websites 9999595223

Buy Fresh and Payment Receive Media.net Account with Website. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs