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.*; /** * CalculatorPanel02 is the panel wrapper for a simple calculator. * It embeds all the necesary components to give a total functionality to * the calculator. * *

* The source code. * * @version 0.9, 1996.06.04 * @author Sorin Lazareanu */ public class CalculatorPanel02 extends CalculatorPanel implements CalcConstants { PrinterPanel01 printer; NumDisplayPanel01 display; Processor01 cpu; KeypadPanel01 keypad; LogoPanel02 logo; /** * Constructs a new panel. */ public CalculatorPanel02() { super(); printer = new PrinterPanel01(); display = new NumDisplayPanel01(printer); cpu = new Processor01((CalcDisplay)display); keypad = new KeypadPanel01((CalcCPU)cpu); logo = new LogoPanel02(); configure(); } /** * Constructs a new panel. * @param parentApplet the original call is from an CalculatorApplet. This information is used to send back sound related messages. * @see CalculatorApplet */ public CalculatorPanel02(CalculatorApplet parentApplet) { super(); printer = new PrinterPanel01(); display = new NumDisplayPanel01(printer); cpu = new Processor01((CalcDisplay)display); keypad = new KeypadPanel01((CalcCPU)cpu, parentApplet); logo = new LogoPanel02(); configure(); } /** * Prepares the layout of the panel */ public void configure() { GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); GridBagLayoutHelper aHelper; printer.configure(); display.configure(); logo.configure(); keypad.configure(); setLayout(gridBag); setFont(new Font(HELVETICA, Font.PLAIN, 14)); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(2, 2, 2, 2); aHelper = new GridBagLayoutHelper(this, gridBag, c, 10, 15); aHelper.addComponent(0, 0, 5, 15, printer); display.configure(); aHelper.addComponent(5, 0, 5, 2, display); display.configure(); aHelper.addComponent(5, 2, 5, 12, keypad); keypad.configure(); aHelper.addComponent(5, 14, 5, 1, logo); logo.configure(); } /** * Sends key events to the keypad panel. */ public boolean keyDown(Event evt, int iKey) { return keypad.keyDown(evt, iKey); } /** * Sends key events to the keypad panel. */ public boolean keyUp(Event evt, int iKey) { return keypad.keyUp(evt, iKey); } /** * Stops the threads in the logo and display panels. */ public void stop() { logo.stop(); display.stop(); } public String toString() { return "CalculatorPanel02 extends " + super.toString(); } }