11
Capture events with a WindowAdapter
- import java.awt.Frame;
- import java.awt.event.*;
- public class SimpleWindow3 {
- static Frame appwin;
- public static void main(String[] args) {
- appwin = new Frame("Application");
- appwin.addWindowListener(new ApplicationWindowAdapter());
- appwin.setBounds(100, 100, 300, 200);
- appwin.setVisible(true);
- }
- }
- class ApplicationWindowAdapter extends WindowAdapter {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- }
- import java.awt.Frame;
- import java.awt.event.*;
- public class SimpleWindow4 {
- static Frame appwin;
- public static void main(String[] args) {
- appwin = new Frame("Application");
- appwin.addWindowListener((new SimpleWindow4()).new ApplicationWindowAdapter());
- appwin.setBounds(100, 100, 300, 200);
- appwin.setVisible(true);
- }
- class ApplicationWindowAdapter extends WindowAdapter {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- }
- }
- import java.awt.Frame;
- import java.awt.event.*;
- public class SimpleWindow5 {
- static Frame appwin;
- public static void main(String[] args) {
- appwin = new Frame("Application");
- appwin.addWindowListener(new ApplicationWindowAdapter());
- appwin.setBounds(100, 100, 300, 200);
- appwin.setVisible(true);
- }
- static class ApplicationWindowAdapter extends WindowAdapter {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- }
- }
Comments