title: What is a Java NullPointerException?
body: <p>I created a Java Application and get this Exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at java.awt.Container.addImpl(Unknown Source)
      at java.awt.Container.add(Unknown Source)
      at javax.swing.JFrame.addImpl(Unknown Source)
      at java.awt.Container.add(Unknown Source)
      at Executer.&lt;init&gt;(Executer.java:21)
      at Executer.main(Executer.java:14 
  </code></pre>
  
  <p>Here is the code: </p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  
  public class Executer {
  
  private JLabel lblCommand;
  private JTextField txtEnter;
  private JButton btNext, btPrevious;
  private JPanel panel;
  
  public static void main(String[] args) {
      new Executer();
  }
  public Executer() {
      JFrame frame = new JFrame("Execute Script");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(900,400);
      frame.setVisible(true);
      frame.add(panel); 
      frame.setVisible(true);
      MyPanel();
      Text();
      Buttons();
      Fields();
  }
  public void MyPanel() {
      panel = new JPanel();
      panel.setLayout(null);
  }
  public void Text(){
      lblCommand = new JLabel("Enter Here");
      lblCommand.setBounds(135, 50, 150, 20);
      Font styleOne = new Font("Arial", Font.BOLD, 13);
      lblCommand.setFont(styleOne);
      panel.add(lblCommand);
  }
  
  public void Fields () {
      txtEnter = new JTextField();
      txtEnter.setBounds(210, 50, 150, 20);
      panel.add(txtEnter);
  }
  public void Buttons() {
      btNext = new JButton ("Next");
      btNext.setBounds(380,325,100,20);
      panel.add(btNext);
  
      btPrevious = new JButton ("Previous");
      btPrevious.setBounds(260,325,100,20);
      panel.add(btPrevious);
  }}
  </code></pre>
  
  <p>What is a NullPointerException?  How would I find out?</p>