title: Java calling a method from a different class
body: <p>I'm doing some pretty basic coding, trying to call a method from a different class but for some reason I'm getting a null pointer exception whenever I try to call any method from any different class. I think I've created the instances of the class correctly but I'm not sure. If anybody can explain what's going wrong to me I'd appreciate it.</p>
  
  <p>here is the class that makes the call:</p>
  
  <pre><code> public class Menu extends JPanel implements ActionListener{
  
  Skeleton skeleton;
  Board board;
  
  public Menu(){
  
      setBackground(Color.BLACK);
  
      JButton button = new JButton("hello");  
      button.addActionListener(this);
      this.add(button);
  }
  
  public JPanel getPanel(){
      return this;
  }
  
  @Override
  public void actionPerformed(ActionEvent e) {
      board.boardTest();
  }
  }
  </code></pre>
  
  <p>and here is the class containing the method</p>
  
  <pre><code>public class Board extends JPanel{
  
  public Board(){
  setBackground(Color.WHITE);
  }
  
  public JPanel getPanel(){
      return this;
  }
  
  public void boardTest(){
      System.out.print("hello");
  }
  }
  </code></pre>
  
  <p>As you can see, whenever the user clicks the button it should print out 'hello'.</p>