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.*; /** * CalculatorPanel03 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 CalculatorPanel03 extends CalculatorPanel implements CalcConstants { NumDisplayPanel01 display; Processor01 cpu; KeypadPanel02 keypad; LogoPanel02 logo; /** * Constructs a new panel. */ public CalculatorPanel03() { super(); display = new NumDisplayPanel01(); cpu = new Processor01((CalcDisplay)display); keypad = new KeypadPanel02((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 CalculatorPanel03(CalculatorApplet parentApplet) { super(); display = new NumDisplayPanel01(); cpu = new Processor01((CalcDisplay)display); keypad = new KeypadPanel02((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; 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, 6, 15); aHelper.addComponent(0, 0, 6, 2, display); display.configure(); aHelper.addComponent(0, 2, 6, 12, keypad); keypad.configure(); aHelper.addComponent(0, 14, 6, 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(); } }