title: How do i fix Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException error
body: <p>My code is experiencing runtime error where Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException would appear. How do I fix it by making the number i insert in the JTextField not a null and instead a number for my price calculation? Thank you in advance for your kind help! Feel free to point out how i can improve the design of the gui as well!</p>
  
  <pre><code>import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.ComponentOrientation;
  import java.awt.Font;
  import java.awt.GridLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.BorderFactory;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JTextField;
  
  public class LunchGUI implements ActionListener {
  
  static JFrame frame;
  static JPanel topPanel,panel;   
  static JLabel adult,kid,salad,dessert,price;
  static JTextField adultq,kidq,saladq,dessertq;
  static JButton confirm;
  
  public static void main(String []args) {
  
      Font font = new Font("Courier", Font.BOLD,24);
      Color Color = new Color(249,206,188);
  
      frame = new JFrame("Lunch Menu");
      //define a new layout
      frame.setLayout(new BorderLayout());
      //panel for label 
      topPanel = new JPanel();
      panel = new JPanel();
      panel.setBackground(Color);
      topPanel.setBackground(Color);
      panel.setLayout(new GridLayout(5, 2, 0, 20));
      panel.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
      panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);     
  
      adult = new JLabel("  Adult Lunch Set $20 Quantity :");            
      adult.setFont(font);
      adult.setBackground(java.awt.Color.CYAN);
      adult.setOpaque(true);
  
      adultq = new JTextField ("0");
      adultq.setFont(font);
      adultq.setBackground(java.awt.Color.CYAN);
      adultq.setOpaque(true);
  
      kid = new JLabel("  Kids Lunch Set $12  Quantity :");            
      kid.setFont(font);
      kid.setBackground(java.awt.Color.CYAN);
      kid.setOpaque(true);
  
      kidq = new JTextField ("0");
      kidq.setFont(font);
      kidq.setBackground(java.awt.Color.CYAN);
      kidq.setOpaque(true);
  
      salad = new JLabel("  Salad Side $4       Quantity :");            
      salad.setFont(font);
      salad.setBackground(java.awt.Color.CYAN);
      salad.setOpaque(true);
  
      saladq = new JTextField ("0");
      saladq.setFont(font);
      saladq.setBackground(java.awt.Color.CYAN);
      saladq.setOpaque(true);
  
      dessert = new JLabel("  Dessert $5          Quantity :");            
      dessert.setFont(font);
      dessert.setBackground(java.awt.Color.CYAN);
      dessert.setOpaque(true);
  
      dessertq = new JTextField ("0");
      dessertq.setFont(font);
      dessertq.setBackground(java.awt.Color.CYAN);
      dessertq.setOpaque(true);
  
      confirm = new JButton("Confirm");            
      confirm.setFont(font);
      confirm.setBackground(java.awt.Color.CYAN);
      confirm.setOpaque(true);
  
      JLabel label = new JLabel("What would you like to order?");
      label.setFont(font);
  
      JLabel price = new JLabel("2323");
      price.setFont(font);
      price.setBackground(Color);
      price.setOpaque(true);
  
      panel.add(adult);
      panel.add(adultq);
      panel.add(kid);
      panel.add(kidq);
      panel.add(salad);
      panel.add(saladq);
      panel.add(dessert);
      panel.add(dessertq);
      panel.add(confirm);     
      panel.add(price);
  
      topPanel.add(label);
      topPanel.setSize(200, 30);
      //rearrange panels on frame
      frame.add(topPanel, BorderLayout.NORTH);
      frame.add(panel, BorderLayout.CENTER);
  
      frame.setSize(1000, 800);
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      confirm.addActionListener(new LunchGUI());
  }
  @Override
  public void actionPerformed(ActionEvent e) {
      int adultamt = Integer.parseInt(adultq.getText());
      int kidamt = Integer.parseInt(kidq.getText());
      int saladamt = Integer.parseInt(saladq.getText());
      int dessertamt = Integer.parseInt(dessertq.getText());
      int total = (20*adultamt)+(14*kidamt)+(4*saladamt)+(5*dessertamt);
  
      price.setText(String.valueOf(total));
  
  }
  
  
  }
  </code></pre>