J2EEOnline
GofPatterns OOPortal
prev prev
  Course navigation
  The Local Inner program
The Local Inner program
The LocalInner program is a minimal window program. The LocalInner constructor declares a local inner class named WindowHandler, which is used to handle the WindowEvent that is generated when the user attempts to close the window.
The WindowHandler class is a small class that is created and used within the scope that it is needed.
The LocalInner program
importjava.awt.*;
importjava.awt.event.*;
classLocalInner
extendsFrame {
public static voidmain(String[] args) {
  new LocalInner();
 }
LocalInner() {
	classWindowHandler
	extendsWindowAdapter {
	public voidwindowClosing(WindowEvent e) {
  System.exit(0);
  }
}
      addWindowListener(new WindowHandler());
      pack();
      setSize(400,400);
      show();
     }
    }
  Course navigation