package polarDust.home; /* * 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 polarDust.calculator.*; import java.awt.*; import java.applet.*; /** * This class is used to instantiate an application by calling * CalculatorPanelxx classes.
* It takes one parameter: the code of the calculator. * The default is 01.
* Example:
java Calculator 01
instantiates CalculatorPanel01
* *

Source code * * @version 0.9, 1996.06.04 * @author Sorin Lazareanu */ public class Calculator extends Frame { boolean bInAnApplet = true; /** The panel to be instantiated. */ CalculatorPanel calcPanel; public Calculator(String arg) { super(); new CalcHashtable(); if (arg.equals("02")) calcPanel = new CalculatorPanel02(); if (arg.equals("03")) calcPanel = new CalculatorPanel03(); if (calcPanel == null) calcPanel = new CalculatorPanel01(); configure(); } /** Private method. Prepares the layout of the frame */ private void configure() { GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); GridBagLayoutHelper aHelper; setLayout(gridBag); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 0, 0, 0); aHelper = new GridBagLayoutHelper(this, gridBag, c, 1, 1); aHelper.addComponent(0, 0, 1, 1, calcPanel); calcPanel.configure(); } /** Callback method. Handles some clean-up before the end of application, killing the threads that paint. These threads require a runnable 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 had stop running. calcPanel.stop(); System.exit(0); } } return super.handleEvent(e); } /** Instantiates a new Calculator object. */ public static void main(String args[]) { String arg = "01"; Calculator aFrame; Insets insets; if (args.length > 0) arg = args[ 0 ]; aFrame = new Calculator(arg); insets = aFrame.insets(); aFrame.bInAnApplet = false; aFrame.setTitle("Calculator" + arg); aFrame.pack(); aFrame.show(); } }