/**
* @author Igor Kholodov, Bristol Community College
*
* <code>application</code> package is a namespace for the classes
* of the application.
*/
package application;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.text.*;
/**
* <code>FrameApplication</code> is the base class for UI window
* of the application.
*/
public class FrameApplication extends javax.swing.JFrame
{
// ----- Operations ----------
/**
* Class constructor takes care of all basic setup steps.
*/
public FrameApplication(String aCaption)
{
super(aCaption);
setSystemLookFeel();
// Proper close-down procedure:
this.addWindowListener(new ApplicationFrameClosing());
} // method: FrameApplication
/**
* Sets the frame size
*/
private void setFrameDimension()
{
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int origin_x = screen.width / 4;
int origin_y = screen.height / 4;
int width = screen.width * 2 / 7;
int height = screen.height * 2 / 7;
this.setBounds(origin_x, origin_y, width, height);
} // method: setFrameDimension
// ----- Static Operations ----------
/**
* Sets OS-specific look and feel
*/
private static void setSystemLookFeel()
{
// Force to come up in the system look and feel
String laf = UIManager.getSystemLookAndFeelClassName();
try
{
UIManager.setLookAndFeel(laf);
}
catch (UnsupportedLookAndFeelException exc)
{
System.err.println("Unsupported: " + laf);
}
catch (Exception exc)
{
System.err.println("Error loading " + laf);
}
}// method: setSystemLookFeel
// ----- Inner classes ----------
/**
* <code>ApplicationFrameClosing</code> object catches window events
*/
public class ApplicationFrameClosing extends java.awt.event.WindowAdapter
{
// ----- Operations ----------
/**
* Catches event and exits the program
*/
public void windowClosing(java.awt.event.WindowEvent event)
{
System.exit(0);
} // method: windowClosing
} // class: ApplicationFrameClosing
} // class: FrameApplication