Class Deposit

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class Deposit extends Api
Deposit class is a JPanel that allows the user to deposit money into their account. It contains a title, radio buttons for payment method selection (Free Money or Card Number), text fields for payment info and deposit amount, and buttons for submitting or canceling the deposit. It validates the input and performs the deposit operation. If the user clicks the deposit button, it will call the Api.deposit(Double) or Api.deposit(BigDecimal, Double) method depending on the selected payment method. If the user clicks the cancel button, it will revert the fields to their initial values and switch the card back to the Main panel.
See Also:
  • Field Details

    • title

      JLabel title
      Label for the title of the deposit panel.
    • freeMoney

      JRadioButton freeMoney
      Radio button for selecting the payment method as "Free Money".
    • fromCard

      JRadioButton fromCard
      Radio button for selecting the payment method as "Card Number".
    • radioContainer

      JPanel radioContainer
      Container for the radio buttons.
    • paymentMethod

      ButtonGroup paymentMethod
      Group of radio buttons for selecting the payment method.
    • paymentInfo

      JTextField paymentInfo
      Text field for the payment info.
    • depositAmount

      JTextField depositAmount
      Text field for the deposit amount.
    • paymentInfoLabel

      JLabel paymentInfoLabel
      Label for the paymentInfo field
    • depositAmountLabel

      JLabel depositAmountLabel
      Label for the depositAmount field
    • submitBtn

      JButton submitBtn
      Button to submit the deposit request
    • cancelBtn

      JButton cancelBtn
      Button to revert the fields to their initial values
  • Constructor Details

    • Deposit

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

    • submitBtnHandler

      private void submitBtnHandler(ActionEvent e)
      Handles the submit button click event. Validates the input fields and performs the deposit operation. If the input is valid, it calls the appropriate deposit method and updates the user information. If an error occurs, it shows an error message dialog. Finally, it reverts the fields to their initial values and switches the card back to the Main panel.
      Parameters:
      e - the event that triggered the method
    • cancelBtnHandler

      private void cancelBtnHandler(ActionEvent e)
      Handles the cancel button click event. Reverts the fields to their initial values and switches the card back to the Main panel.
      Parameters:
      e - the event that triggered the method