On my journey through my java Book, I'm starting to learn about frames.
When you click the "X" to close the window, this program does not completely terminate for some reason, you have to use ctrl^c in the console to exit it. I do not understand why, unless this approach is deprecated. Please Help.
WindowClosingTest.java
// WindowClosingTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class WindowClosingTest extends JFrame { JTextArea frameTextArea; Container frameContainer; public WindowClosingTest() { super("WindowClosingTest Application"); init(); } public void init() { addWindowListener(new WindowCloser()); frameContainer = getContentPane(); frameTextArea = new JTextArea("\t Window Closing Test Class.", 50, 50); frameTextArea.setEditable(true); frameTextArea.setLineWrap(true); frameContainer.add(frameTextArea); setSize(520, 300); setVisible(true); } public static void main(String Args[]) { new WindowClosingTest(); } }//end class
WindowCloser.java
//WindowCloser.java import java.awt.event.*; import javax.swing.*; public class WindowCloser extends WindowAdapter { public WindowCloser(){} public void windowClosing(WindowEvent wE) { System.exit(0); } }//end class