title: Error for JButton ActionListener
body: <p>I'm having a problem while adding an ActionListener for JButton, please help solving this issue.</p>
  
  <p>Error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
  at searchDB.searchDB(searchDB.java:11)
  at Ramses.main(Ramses.java:35)
  </code></pre>
  
  <p>Main Class: Ramses.java</p>
  
  <pre><code>import javax.swing.JFrame;
  import ...........;
  
  public class Ramses {
  
  public static void main(String[] args) {
      // TODO Auto-generated method stub
  
      Gui GuiObject = new Gui();
      GuiObject.Gui();
  
      searchDB searchObject = new searchDB();
      searchObject.searchDB(); //error here
  
  }
  }
  </code></pre>
  
  <p>Class where JButton is declared: Gui.java</p>
  
  <pre><code>import javax.swing.*;
  import........;
  
  public class Gui {
  public static JButton btnUpdate;
  public void Gui() {
  JButton btnSearch = new JButton("Search");
      btnSearch.setBounds(463, 112, 91, 23);
      btnSearch.setVisible(true);
      pnUpper.add(btnSearch);
  
   }
  }
  </code></pre>
  
  <p>Class where JButton ActionListener is implemented: searchDB.java</p>
  
  <pre><code>import javax.swing.*;
  
  public class searchDB{
  
  public void searchDB(){
  
      HandlerClass handler = new HandlerClass();
      Gui.btnSearch.addActionListener(handler); //error in this line
  
  }
  private class HandlerClass implements ActionListener{
  
      @Override
      public void actionPerformed(ActionEvent event) {
          // TODO Auto-generated method stub
          String cstmrSearch = (String) Gui.cbCustomer.getSelectedItem();
          System.out.println("Selected Customer is :"+cstmrSearch);
      }
  
  
  }
  }
  </code></pre>
  
  <p>Any ideas what is the problem in this code??</p>