![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
JFrame
class, then define an inner subclass
of the WindowListener
class, then define an appropriate
windowClosing
method for that inner class, and then connect an
instance of the inner class to the JFrame
subclass instance using
addWindowListener
:
import javax.swing.*; import java.awt.event.*; public class application name extends JFrame { public static void main (String argv []) { new application name (title); } public application name(String title) { super(title); setSize(width, height); addWindowListener(new LocalWindowListener()); show(); } // Define window listener private class LocalWindowListener extends WindowAdapter { public void windowClosing(WindowEvent e) { System.exit(0); } } }