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.*; /** * Calculator01 is a frame hosting a simple calculator.
* Provides the meaning of instantiating the calculator in an * application. * *

* The source code. * * @version 0.9, 1996.06.04 * @author Sorin Lazareanu */ public class Calculator01 extends Frame { boolean bInAnApplet = true; CalculatorPanel01 panel; /** * Constructs a new frame. */ public Calculator01() { super(); panel = new CalculatorPanel01(); configure(); } /** * Constructs a new frame. The original call is from an CalculatorApplet. * This information is used to send back sound related messages. * @see CalculatorApplet */ public Calculator01(CalculatorApplet parentApplet) { super(); panel = new CalculatorPanel01(parentApplet); configure(); } /** * Configures the layout of this frame. Invokes a CalculatorPanel01. */ 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 Calculator01 object. Doesn't take parameters. */ public static void main(String args[]) { Calculator01 aFrame = new Calculator01(); Insets insets = aFrame.insets(); aFrame.bInAnApplet = false; aFrame.setTitle("Calculator"); aFrame.resize( aFrame.preferredSize().width, aFrame.preferredSize().height ); aFrame.show(); } public String toString() { return "Calculator01 extends " + super.toString(); } }