Class MainUI

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class MainUI extends JPanel
The MainUI class represents the panel containing all calculator buttons.

It is responsible for:

  • Creating and styling the calculator buttons.
  • Setting up the layout for the button panel.
  • Attaching action listeners to each button, triggering operations.

This class integrates with BaseUI and uses Logic to perform the necessary calculations.

See Also:
  • Field Details

    • buttons

      private final JButton[] buttons
      Array of buttons representing the calculator keys.
    • buttonLabel

      private final String[] buttonLabel
      Labels for the buttons, representing digits, operations, and functions.
    • input

      protected StringBuilder input
      The current input being displayed on the calculator.

      It is updated as the user clicks buttons.

    • inputString

      protected String inputString
      The string representation of the current input.
    • result

      protected double result
      The result of the last calculation performed.
  • Constructor Details

    • MainUI

      MainUI(BaseUI baseUiInstance)
      Constructs the MainUI panel and initializes the calculator buttons.

      It configures the panel layout, creates buttons with appropriate labels, sets colors, fonts, and attaches action listeners for operations.

      Parameters:
      baseUiInstance - The BaseUI instance to access global properties like colors and theme.