// @topic T11657 Swing demo A5 -- Sublassing main application frame
// @brief class ApplicationFrame extends javax.swing.JFrame, Dimension, JPanel, java.awt.event.WindowAdapter, JFrame.addWindowListener
/**
 * @author ik
 */

package pckg;

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