title: Java login screen how to read and save to local database
body: <p>Hi i am trying to make a <code>GUI login screen</code> that can read and save passwords(plain text is fine i dont need encryption) and usernames.
  But i am not sure how to do that so far i have this. 
  I would prefer for them to be stored in a local file not mysql but that would be ok.  </p>
  
  <p><a href="https://i.stack.imgur.com/vkugX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vkugX.png" alt="enter image description here"></a>  </p>
  
  <pre><code>package com.edu4java.swing.tutrial4;
  
  import java.awt.Component;
  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 LoginView3 {
  
      public static void main(String[] args) {
          JFrame frame = new JFrame("Login");
          frame.setSize(300, 150);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          placeComponents(frame);
          frame.setVisible(true);
      }
  
      private static void placeComponents(JFrame frame) {
          frame.setLayout(null);
  
          JLabel userLabel = new JLabel("User");
          userLabel.setBounds(10, 10, 80, 25);
          frame.add(userLabel);
  
          JTextField userText = new JTextField(20);
          userText.setBounds(100, 10, 160, 25);
          frame.add(userText);
  
          JLabel passwordLabel = new JLabel("Password");
          passwordLabel.setBounds(10, 40, 80, 25);
          frame.add(passwordLabel);
  
          JPasswordField passwordText = new JPasswordField(20);
          passwordText.setBounds(100, 40, 160, 25);
          frame.add(passwordText);
  
          JButton loginButton = new JButton("login");
          loginButton.setBounds(10, 80, 80, 25);
          frame.add(loginButton);
  
          JButton registerButton = new JButton("register");
          registerButton.setBounds(180, 80, 80, 25);
          frame.add(registerButton);
  
          ActionListener loginButtonListener = new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  JButton source = (JButton) e.getSource();
                  JOptionPane.showMessageDialog(source, source.getText()
                          + " button has been pressed");
              }
          };
          loginButton.addActionListener(loginButtonListener);
  
          registerButton.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  JOptionPane.showMessageDialog((Component) e.getSource(),
                          "button has been pressed");
              }
          });
      }
  
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>package com.edu4java.swing.tutrial4;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.JButton;
  import javax.swing.JOptionPane;
  
  public class MyButtonListener implements ActionListener {
      @Override
      public void actionPerformed(ActionEvent e) {
          JButton source = (JButton) e.getSource();
          JOptionPane.showMessageDialog(source, source.getText() + " button has been pressed");
      }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>package com.edu4java.swing.tutrial4;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.JOptionPane;
  
  public class LoginButtonListener implements ActionListener {
      @Override
      public void actionPerformed(ActionEvent e) {
          JOptionPane.showMessageDialog(null, "login button has been pressed");
      }
  }
  </code></pre>