title: addActionLister parameter
body: <p>I am getting expected output when i am using "<strong>this</strong>" reference in addActionListener() call, how can I achieve it using the object call directly ? When i am using jb.addActionListener(new EventHandling1());</p>
  
  <p>I am getting error -"Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException".</p>
  
  <p>Also which object needs to be passed to this method addActionListener() ? </p>
  
  <p>Below is the code which is failing with the above mentioned error.</p>
  
  <pre><code>import javax.swing.*;
  
  import java.awt.event.*;
  
  public class EventHandling1 implements ActionListener {
  
      JButton jb;
  
      public static void main(String[] args) {
  
          EventHandling1 eh = new EventHandling1();
          eh.go();
      }
  
      public void go() {
          JFrame jf = new JFrame();
          jb = new JButton("New button");
          jb.addActionListener(new EventHandling1());
  
          jf.getContentPane().add(jb);
          jf.setVisible(true);
          jf.setSize(700, 500);
  
      }
  
      public void actionPerformed(ActionEvent event) {
          jb.setText("Pressed!!");
  
      }
  
  }
  </code></pre>