Class WithdrawJar

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class WithdrawJar extends Api
WithdrawJar class is a GUI component that allows users to withdraw money from a jar. It extends the Api class and implements the necessary components and layout for the withdrawal process.

It includes fields for the jar title and amount to withdraw, as well as buttons for withdrawing and canceling the action. The class handles user input validation and communicates with the database to perform the withdrawal operation. It also updates the UI components to reflect the changes after the withdrawal.
See Also:
  • Field Details

    • gbLayout

      GridBagLayout gbLayout
      GridBagLayout object used for layout management.
    • gbc

      GridBagConstraints object used for layout management.
    • title

      JLabel title
      Label for the title of the withdrawal screen.
    • jarId

      int jarId
      ID of the jar to withdraw from.
    • titleLabel

      JLabel titleLabel
      Label to display the title of the jar.
    • amountLabel

      JLabel amountLabel
      Label to display the amount available in the jar.
    • titleField

      JTextField titleField
      Field to display the title of the jar.
    • amountField

      JTextField amountField
      Field for entering the amount to withdraw.
    • withdrawBtn

      JButton withdrawBtn
      Button to withdraw money from the jar.
    • cancelBtn

      JButton cancelBtn
      Button to cancel the withdrawal action.
  • Constructor Details

    • WithdrawJar

      WithdrawJar()
      Constructs a WithdrawJar object.
  • Method Details

    • withdrawHandler

      void withdrawHandler(ActionEvent event)
      Handles the action event triggered by the withdraw button. Validates the user input, checks if the withdrawal amount is valid, and performs the withdrawal operation. If the withdrawal is successful, it updates the UI components and switches back to the Jars view.
      Parameters:
      event - The action event triggered by the withdraw button.
    • cancelHandler

      void cancelHandler(ActionEvent event)
      Handles the action event triggered by the cancel button. Clears the input fields and switches back to the Jars view.
      Parameters:
      event - The action event triggered by the cancel button.
    • setTitleAndID

      public void setTitleAndID(String title, int id)
      Sets the title and ID of the jar to be withdrawn from. This method is used to initialize the jar information in the UI.
      Parameters:
      title - the title of the jar
      id - the id of the jar
    • setAmountLabel

      public void setAmountLabel(String amount)
      Sets the amount label to display the available amount in the jar. This method is used to update the UI with the current amount available for withdrawal.
      Parameters:
      amount - the amount of money available in the jar