Class Send

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class Send extends Api
Send class is a JPanel that allows the user to send money to another person's account. It contains a title, radio buttons for selecting between new and recent entries, text fields for entering the recipient's name, card number, and amount to send, and buttons for submitting or canceling the transaction.

If the user clicks the send button, it will call the Api.send(double, BigDecimal, String) method with the entered data. 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 panel.
    • newRecentGroup

      ButtonGroup newRecentGroup
      ButtonGroup for the new/recent buttons.
    • newRecentContainer

      JPanel newRecentContainer
      Container for the new/recent buttons.
    • inputsContainer

      JPanel inputsContainer
      Container that wraps the text fields and combo boxes containers to allow switching between the two.
    • textFieldsContainer

      JPanel textFieldsContainer
      Container for the text fields.
    • comboBoxContainer

      JPanel comboBoxContainer
      Container for the combo boxes.
    • newBtn

      JButton newBtn
      Button to switch to entering new payment info.
    • recentBtn

      JButton recentBtn
      Button to switch to using recent entries.
    • nameL

      JLabel nameL
      Label for the name field.
    • numberL

      JLabel numberL
      Label for the card number field.
    • amountL

      JLabel amountL
      Label for the amount field.
    • nameLCombo

      JLabel nameLCombo
      Label for the name combo box.
    • numberLCombo

      JLabel numberLCombo
      Label for the card number combo box.
    • name

      Field for the name.
    • number

      JTextField number
      Field for the card number.
    • amount

      JTextField amount
      Field for the amount to be sent.
    • nameBox

      JComboBox<String> nameBox
      ComboBox for the name.
    • numberBox

      JComboBox<String> numberBox
      ComboBox for the card number.
    • submitBtn

      JButton submitBtn
      Button to submit the transaction.
    • cancelBtn

      JButton cancelBtn
      Button to cancel the transaction.
    • recentEntriesList

      List<String> recentEntriesList
      List of recent entries read from the file.
  • Constructor Details

    • Send

      Send()
      Constructs a Send object.
  • Method Details

    • selectionHandler

      private void selectionHandler(ActionEvent e)
      Handles the selection of the "New" or "Recent" buttons. It switches the input fields between text fields and combo boxes.
      Parameters:
      e - the event that triggered the method
    • comboBoxHandler

      private void comboBoxHandler(ActionEvent e)
      Handles the selection logic of the combo boxes. It sets the selected index of the other JComboBox to be the same as the one that was used to make the selection.
      Parameters:
      e - the event that triggered the method
    • readRecentEntries

      private void readRecentEntries()
      Reads the recent entries from a file and stores them in a list. If the file does not exist, it initializes an empty list. This method is called when the class is instantiated.

      It reads the entries from the file called "recentTransfers.txt". If the file does not exist, it initializes an empty list.
    • savePaymentInfo

      private void savePaymentInfo(List<String> entries)
      Saves the payment information to a file. This method is called when the user clicks the send button. It writes the entries to a file called "recentTransfers.txt". If the file does not exist, it creates a new one.

      It takes a List of entries as input and writes each entry to the file. Each entry is written on a new line.
      Parameters:
      entries - the list of entries to be saved
    • submitBtnHandler

      private void submitBtnHandler(ActionEvent e)
      Handles the submit button click event.

      Validates the input fields and performs the send operation. If the input is valid, it calls the Api.send(double, BigDecimal, String) method with the entered data.
      Parameters:
      e - the event that triggered the method
    • cancelBtnHandler

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