Prac13 (Use of WindowAdapter Class)
Prac13 (Use of WindowAdapter Class)
Prac13 (Use of WindowAdapter Class)
import java.awt.event.*;
public class WindowExDemo extends Frame implements
WindowListener{
WindowExDemo(){
setTitle("Window Listener");
setBounds(100,200,200,250);
setVisible(true);
addWindowListener(this);
}
public void windowClosing(WindowEvent e){
System.out.println(("Window Closing"));
dispose(); System.exit(0);
}
public void windowOpened(WindowEvent e){
System.out.println("Window Open");
}
public void windowClosed(WindowEvent e){
System.out.println("Window Close");
}
public void windowActivated(WindowEvent e){
System.out.println("Window Activated");
}
public void windowDeactivated(WindowEvent e){
System.out.println("Window Deactivated");
}
public void windowIconified(WindowEvent e){
System.out.println("Window Iconified");
}
public void windowDeiconified(WindowEvent e){
System.out.println("Window Deiconified");
}
public static void main(String args[]){
WindowExDemo WD=new WindowExDemo();
}
}
Output :-
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
jb.addActionListener((new ActionListener() {
System.out.println("Oops!!");
} }));
in.add(jb);
in.pack();
in.setVisible(true);
} }
Output :-