package polarDust.calculator;
/*
* Copyright (c) 1996 Sorin Lazareanu, All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies.
*
*/
import java.awt.*;
/**
* Calculator02 is the frame hosting a simple calculator with paper tape.
* Provides the meaning of instantiating the calculator in an
* application.
*
*
* The source code.
*
* @version 0.9, 1996.06.04
* @author Sorin Lazareanu
*/
public class Calculator02 extends Frame {
boolean bInAnApplet = true;
CalculatorPanel02 panel;
/**
* Constructs a new frame.
*/
public Calculator02() {
super();
panel = new CalculatorPanel02();
configure();
}
/**
* Constructs a new frame. The original call is from an CalculatorApplet.
* This information is used to send back sound related messages.
*/
public Calculator02(CalculatorApplet parentApplet) {
super();
panel = new CalculatorPanel02(parentApplet);
configure();
}
/**
* Configures the layout of this frame. Invokes a CalculatorPanel02.
*/
public void configure() {
GridBagLayout gridBag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridwidth = 1;
c.weightx = 1.0;
c.gridy = 0;
c.gridheight = 1;
c.weighty = 1.0;
gridBag.setConstraints(panel, c);
setLayout(gridBag);
add(panel);
}
/**
* Handles the events related to the destruction of the frame.
* Must stop() all the threads that use Screen Updater thread.
*/
public boolean handleEvent(Event e) {
if (e.id == Event.WINDOW_DESTROY) {
if (bInAnApplet) {
dispose();
return false;
} else {
// panel thread is able to repaint even when
// Screen Updater has stop running.
panel.stop();
System.exit(0);
}
}
return super.handleEvent(e);
}
/**
* Instantiates a new Calculator02 object. Doesn't take parameters.
*/
public static void main(String args[]) {
Calculator02 aFrame = new Calculator02();
Insets insets = aFrame.insets();
aFrame.bInAnApplet = false;
aFrame.setTitle("Calculator");
aFrame.resize(
aFrame.preferredSize().width,
aFrame.preferredSize().height
);
aFrame.show();
}
public String toString() {
return "Calculator02 extends " + super.toString();
}
}