Package calculator

Class CalculatorView

All Implemented Interfaces:
Keypad, ImageObserver, MenuContainer, Serializable, Accessible

public class CalculatorView extends Frame implements Keypad
This class represents the model in the MVC architecture. It handles the GUI part of the application.
Since:
24 Aug 2023
Version:
1.0.0
Author:
Shamith Nakka
See Also:
  • Field Details

    • globalFont

      private final Font globalFont
    • icon

      private final Image icon
    • keypad

      protected final Panel keypad
    • textField

      protected final TextField textField
  • Constructor Details

    • CalculatorView

      public CalculatorView()
      Constructs a new CalculatorModel instance. This constructor initializes any required data or resources.
  • Method Details

    • addComponentsToView

      private void addComponentsToView(Component component, int gridx, int gridy, int weightx, int weighty, int... padding)
      This function adds components to the main Frame window w.r.t provided constraint values.
      Parameters:
      component - : java.awt.Component object.
      gridx - : x value on grid.
      gridy - : y value on grid.
      weightx - : weight value of x-coordinate on grid.
      weighty - : weight value of y-coordinate on grid.
      padding - : array of padding value (Top, Left, Bottom, Right).
    • getIconLocation

      private String getIconLocation()
      Returns the absolute path to icon.
      Returns:
      absolutePathToIcon[String]
    • createKeypad

      public final Panel createKeypad()
      This function returns a java.awt.Panel object that contains all the buttons required for a simple calculator.
      Specified by:
      createKeypad in interface Keypad
      Returns:
      keypad[java.awt.Panel] : Panel object.