Ayush Pratical No 13
Ayush Pratical No 13
Ayush Pratical No 13
XIII. Exercise.
Code :-
import java.awt.*;
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");
}
1
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 :-
2
2. Write A Program To Demonstrate The Use Of Anonymous Inner Class.
Code :-
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);
3
Output :-
4
3. Write a Program Using MouseMotionAdapter Class To Implement Only One
Method mouseDragged.
Code :-
import java.awt.*;
import java.awt.event.MouseMotionListener;
import java.awt.event.*;
5
Output :-