Class DepositJar

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class DepositJar extends Api
DepositJar class is a JPanel that allows the user to deposit money into a jar. It contains a form with fields for ID and amount, and buttons for deposit and cancel. It extends the Api class to access the database and update the user information.
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 panel.
    • idLabel

      JLabel idLabel
      Label for the idField.
    • amountLabel

      JLabel amountLabel
      Label for the amountField.
    • idField

      JTextField idField
      Field for the ID of the jar to deposit money into.
    • amountField

      JTextField amountField
      Field for the amount of money to deposit into the jar.
    • depositBtn

      JButton depositBtn
      Button to deposit money into the jar.
    • cancelBtn

      JButton cancelBtn
      Button to reset the input fields and switch back to the Jars panel.
  • Constructor Details

    • DepositJar

      DepositJar()
      Constructs a new DepositJar panel.
  • Method Details

    • depositHandler

      private void depositHandler(ActionEvent e)
      Handles the deposit button click event. Validates the input fields and calls the Api.depositToJar(int, double) method to deposit money into the jar. If the deposit is successful, it updates the user information, resets the input fields and switches the card back to the Jars panel. If an error occurs, it shows an error message.
      Parameters:
      e - the event that triggered the method
    • cancelHandler

      private void cancelHandler(ActionEvent e)
      Handles the cancel button click event. Resets the input fields and switches the card back to the Jars panel.
      Parameters:
      e - the event that triggered the method