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

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