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

Google Advertisment

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

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

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements