|
||
| 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 LocalInner program
The WindowHandler class is a small class that is created and used within the scope that it is needed. 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); show(); } } |
||
|
|
||