/**
* @author Igor Kholodov, Bristol Community College
*
* CIS-75 A5 sample:
* Sublassing main application frame
* Setting the Window Close Box: JFrame.addWindowListener
*/
package application;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.text.*;
public class ApplicationFrame extends javax.swing.JFrame
{
// ----- Operations ----------
public ApplicationFrame(String aCaption)
{
super(aCaption);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int width = screen.width * 3 / 4;
int height = screen.height * 3 / 4;
this.setBounds(screen.width / 8, screen.height / 8, width, height);
JPanel jpan = new JPanel();
this.getContentPane().add(jpan);
JButton jbut = new JButton("Hello");
jpan.add(jbut);
this.setVisible(true);
// Proper close-down procedure.
this.addWindowListener(new ApplicationFrameClosing());
} // method: ApplicationFrame
// ----- Inner classes ----------
public class ApplicationFrameClosing extends java.awt.event.WindowAdapter
{
// ----- Operations ----------
public void windowClosing(java.awt.event.WindowEvent event)
{
System.exit(0);
} // method: windowClosing
} // class: ApplicationFrameClosing
} // class: ApplicationFrame