title: ActionListener in Java doesn't work for me
body: <p>I was watching a tutorial on how to crate a login system in Java and when I recreated it, it just wouldn't work. When I start the program I can see all my JLabels, JButtons, and my JPasswordField but when I press the reset button I get hit with this error message in the console</p>
  <pre><code>in thread &quot;AWT-EventQueue-0&quot; java.lang.NullPointerException: Cannot invoke java.util.EventObject.getSource()&quot; because &quot;this.e&quot; is null
     at LoginPage.actionPerformed(LoginPage.java:67)
     at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
     at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
     at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
     at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
     at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
     at java.desktop/java.awt.Component.processMouseEvent(Component.java:6636)
     at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
     at java.desktop/java.awt.Component.processEvent(Component.java:6401)
     at java.desktop/java.awt.Container.processEvent(Container.java:2263)
     at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5012)
     at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
     at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
     at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4919)
     at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4548)
     at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4489)
     at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
     at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2764)
     at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
     at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
     at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
     at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
     at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
     at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
     at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
     at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
     at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
     at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
     at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
     at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
     at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
  </code></pre>
  <p>So at this point I thought I had misspelled something and so I copied the code from the guy that was making the tutorial and when I pasted it I got the same message.  At this point I am pretty desperate and I would take any help I can get. TIA to anyone who helps.</p>
  <pre><code>import java.awt.Font;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.EventObject;
  import java.util.HashMap;
  
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JPasswordField;
  import javax.swing.JTextField;
  public class LoginPage  implements ActionListener {
      JFrame frame = new JFrame();
      JButton loginButton = new JButton(&quot;Login&quot;);
      JButton resetButton = new JButton(&quot;Reset&quot;);
      JTextField userIDField = new JTextField();
      JPasswordField userPasswordField = new JPasswordField();
      JLabel userIDLabel = new JLabel(&quot;userID:&quot;);
      JLabel userPasswordLabel = new JLabel(&quot;Password:&quot;);
      JLabel messageLabel = new JLabel(&quot;&quot;);
      HashMap&lt;String,String&gt; logininfo = new HashMap&lt;String,String&gt;();
      private EventObject e; 
      
          LoginPage(HashMap&lt;String,String&gt; loginInfoOriginal){
              logininfo = loginInfoOriginal;
              
              //Labels
              userIDLabel.setBounds(50, 100, 75, 25);
              userPasswordLabel.setBounds(50, 150, 75, 25);
              messageLabel.setBounds(125, 250, 250, 35);
              messageLabel.setFont(new Font(null,Font.ITALIC,25));
              
              //Fields
              userIDField.setBounds(125,100,200,25);
              userPasswordField.setBounds(125,150,200,25);
              
              //Buttons
              loginButton.setBounds(125, 200, 100, 25);
              loginButton.addActionListener(this);
              loginButton.setFocusable(false);
              resetButton.setBounds(225, 200, 100, 25);
              resetButton.setFocusable(false);
              resetButton.addActionListener(this);
              
              //Window
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(420,420);
              frame.setLayout(null);
              frame.setVisible(true);
              frame.add(userIDLabel);
              frame.add(userPasswordLabel);
              frame.add(messageLabel);
              frame.add(userIDField);
              frame.add(userPasswordField);
              frame.add(loginButton);
              frame.add(resetButton);
          }
  
          @Override
          public void actionPerformed(ActionEvent arg0) {
              if(e.getSource()==resetButton); 
                  userIDField.setText(&quot;&quot;);
                  userPasswordField.setText(&quot;&quot;);
          }
  }
  
  </code></pre>