Classes/Objects  «Prev 


Local Inner Program in Java

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

import< java.awt.*;
import <java.awt.event.*;
class< LocalInner extends <Frame {
public static void <main(String[] args) {
  new LocalInner();
 }
  LocalInner() {
    class <WindowHandler extends <WindowAdapter {
      public void <windowClosing(WindowEvent e) {
      System.exit(0);
    }
  }
   addWindowListener(new WindowHandler());
   pack();
   setSize(400,400);
   setVisible(true);
  }
}