Friday, 14 June 2013

window listener demo , frame demo in java awt


import java.awt.*;
import java.awt.event.*;
class MyFrame extends Frame implements WindowListener
{
    public MyFrame()
    {
        setSize(500,500);
        setLocation(100,100);
        addWindowListener(this);
    }
    public void windowDeactivated(WindowEvent we)
    {
        System.out.println("Window is Deactivated");
    }
    public void windowActivated(WindowEvent we)
    {
        System.out.println("Window is Activated");
    }
    public void windowDeiconified(WindowEvent we)
    {
        System.out.println("Window is Deconified");
    }
    public void windowIconified(WindowEvent we)
    {
        System.out.println("Window is Iconified");
    }
    public void windowClosed(WindowEvent we)
    {
        System.out.println("Windos is closed");
    }
    public void windowClosing(WindowEvent we)
    {
        System.out.println("Window is closing");
        System.exit(0);
    }
    public void windowOpened(WindowEvent we)
    {
        System.out.println("Window is Opened");
    }
}
class FrameDemo
{
    public static void main(String []args)
    {
        new MyFrame().setVisible(true);       
    }
}

No comments: