title: Store user/pass from user created account?
body: <p>I'm working on a blank program that will allow a user to create an account so they can store their balance and withdraw/deposit. Once the user enters the username and password, how can I store this information so that the user can log in and see their balance? I"m not necessarily trying to make this so it is extremely secure, I just want to be able to store account information and be able to access it later.</p>
  
  <p>This is the class where they will create the account (still a work in progress):</p>
  
  <pre><code>import java.awt.FlowLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPasswordField;
  import javax.swing.JTextField;
  
  public class CreateAccount extends JFrame implements ActionListener {
  
      JLabel username = new JLabel("Enter your username");
      JTextField enterUsername = new JTextField(null, 15);
      JLabel password = new JLabel("Enter your password");
      JPasswordField enterPassword = new JPasswordField(null, 15);
      JLabel passwordConfirm = new JLabel("Confirm your password.");
      JPasswordField enterConfirmPassword = new JPasswordField(null, 15);
      JButton okButton = new JButton("OK");
  
      public CreateAccount() {
  
          add(username);
          add(enterUsername);
          add(password);
          add(enterPassword);
          add(passwordConfirm);
          add(enterConfirmPassword);
          add(okButton);
  
          okButton.addActionListener(this);
  
          setTitle("New Bank Account Creation");
          setVisible(true);
          setSize(270, 300);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setLayout(new FlowLayout());
  
      }
  
      @Override
      public void actionPerformed(ActionEvent e) {
  
          char[] pass = enterPassword.getPassword();
          String passString = new String(pass);
          char[] passConfirm = enterConfirmPassword.getPassword();
          String passStringConfirm = new String(passConfirm);
  
          String userName = enterUsername.getText();
  
          if (e.getSource() == okButton) {
              if (!passString.equals(passStringConfirm) || userName.equals(null) || passString.equals(null) || passStringConfirm.equals(null)) {
                  JOptionPane.showMessageDialog(null, "Entered an invalid username or password!");
                  enterUsername.setText("");
                  enterPassword.setText("");
                  enterConfirmPassword.setText("");
              }
          }
      }
  }
  </code></pre>
  
  <p>Here is the account class which I would like these accounts to be stored as:</p>
  
  <pre><code>import javax.swing.JOptionPane;
  
  
  public class Account {
      private String name;
      private double balance;
  
      public Account(String name, double balance) {
          getName();
          getBalance();
          this.name = name;
          this.balance = balance;
  
      }
      String getName() {
          return name = JOptionPane.showInputDialog("What is your name?");
      }
      double getBalance() {
          String userBalance = JOptionPane.showInputDialog("How much money would you like to deposit?");
          return balance = Double.parseDouble(userBalance);
      }
      public void setName() {
          this.name = name;
      }
      public void setBalance() {
          this.balance = balance;
      }
  
  }
  </code></pre>