package view;
import javax.swing.*; // to use JFrame.
/**
* Minimal reusable code to create a JFrame with a title and a window event
* listener to call on System.exit() and force termination of the main
* application that creates this JFrame.
* @author D.X. Nguyen
*/
public class Frame0 extends JFrame {
public Frame0(String title) {
// Always call the superclass's constuctor:
super(title);
// Add an anonymous WindowAdapter event handler to call System.exit to
// force termination of the main application when the Frame closes.
// Without it, the main application will still be running even after
// the frame is closed.
// For illustration purpose, we use the full package name for
// WindowAdpater and WindowEvent.
// We could have imported java.awt.event.* and avoid using the full
// package names.
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.out.println(e);
System.exit(0);
}
});
initialize();
}
protected void initialize() {
// Does nothing here.
// Subclasses may do more.
}
}