Exception in thread "main" java.lang.NullPointerException
package Wizard;

import java.awt.event.ActionEvent;
import java.awt.CardLayout;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;


public class WizardDisplay extends JFrame{
 

 static final long serialVersionUID = -1L;

    JPanel cards;  //a panel that uses CardLayout
    JPanel FirstFramePanel,SecondFramePanel,ThirdFramePanel; 
    JLabel label1,label2,label31,label32,label33,label34;
    JTextField text1,text2;
    JButton nextBtn,previousBtn;
    String FirstInput,SecondInput;
 
    private int currentCard = 1;
    private JPanel cardPanel;
    private CardLayout cl;
    
    public WizardDisplay() {
     
     setTitle("WizardDisplay");
                
     cl = new CardLayout();
        cardPanel.setLayout(cl);
     
     //code for first frame
     
     FirstFramePanel = new JPanel(); //use FlowLayout
       
        label1 = new JLabel("Enter The First Term");
        text1 = new JTextField(20);
        nextBtn = new JButton("Next");
        
        FirstFramePanel.add(label1);
        FirstFramePanel.add(text1);
        FirstFramePanel.add(nextBtn);
        
      //code for second frame

        SecondFramePanel = new JPanel(); //use FlowLayout
        
        label2 = new JLabel("Enter The Second Term");
        text2 = new JTextField(20);
        previousBtn = new JButton("Previous");
        
        
        SecondFramePanel.add(label2);
        SecondFramePanel.add(text2);
        SecondFramePanel.add(previousBtn);
        SecondFramePanel.add(nextBtn);
        
        FirstInput = text1.getText();        
        SecondInput = text2.getText();
        
        //code for third frame
        
         ThirdFramePanel = new JPanel(); //use FlowLayout
        
        label31 = new JLabel("First Input---");
        label32 = new JLabel(FirstInput);
        label33 = new JLabel("Second Input---");
        label34 = new JLabel(SecondInput);
        
        ThirdFramePanel.add(label31);
        ThirdFramePanel.add(label32);
        ThirdFramePanel.add(label33);
        ThirdFramePanel.add(label34);
        ThirdFramePanel.add(previousBtn);
        
        cardPanel.add(FirstFramePanel, "1");
        cardPanel.add(SecondFramePanel, "2");
        cardPanel.add(ThirdFramePanel, "3");
        
        
        // for check
        
        nextBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if (currentCard < 3) {
                    currentCard += 1;
                    cl.show(cardPanel, "" + (currentCard));
                }
            }
        });
        
        previousBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if (currentCard > 1) {
                    currentCard -= 1;
                    cl.show(cardPanel, "" + (currentCard));
                }
            }
        });
        
        
        
             
        getContentPane().add(FirstFramePanel);
        
        
   
    }
    

 
 public static void main(String[] args) {
 
     WizardDisplay wizard = new WizardDisplay();
        wizard.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        wizard.setVisible(true); 
  
 }

}



Exception in thread "main" java.lang.NullPointerException
===

package Wizard;

import java.awt.event.ActionEvent;
import java.awt.CardLayout;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;


public class WizardDisplay extends JFrame{
 

 static final long serialVersionUID = -1L;

    JPanel cards;  //a panel that uses CardLayout
    JPanel FirstFramePanel,SecondFramePanel,ThirdFramePanel; 
    JLabel label1,label2,label31,label32,label33,label34;
    JTextField text1,text2;
    JButton nextBtn,previousBtn;
    String FirstInput,SecondInput;
 
    private int currentCard = 1;
    private JPanel cardPanel;
    private CardLayout cl;
    
    public WizardDisplay() {
     
     setTitle("WizardDisplay");
                
     cl = new CardLayout();
        cardPanel.setLayout(cl);
     
     //code for first frame
     
     FirstFramePanel = new JPanel(); //use FlowLayout
       
        label1 = new JLabel("Enter The First Term");
        text1 = new JTextField(20);
        nextBtn = new JButton("Next");
        
        FirstFramePanel.add(label1);
        FirstFramePanel.add(text1);
        FirstFramePanel.add(nextBtn);
        
      //code for second frame

        SecondFramePanel = new JPanel(); //use FlowLayout
        
        label2 = new JLabel("Enter The Second Term");
        text2 = new JTextField(20);
        previousBtn = new JButton("Previous");
        
        
        SecondFramePanel.add(label2);
        SecondFramePanel.add(text2);
        SecondFramePanel.add(previousBtn);
        SecondFramePanel.add(nextBtn);
        
        FirstInput = text1.getText();        
        SecondInput = text2.getText();
        
        //code for third frame
        
         ThirdFramePanel = new JPanel(); //use FlowLayout
        
        label31 = new JLabel("First Input---");
        label32 = new JLabel(FirstInput);
        label33 = new JLabel("Second Input---");
        label34 = new JLabel(SecondInput);
        
        ThirdFramePanel.add(label31);
        ThirdFramePanel.add(label32);
        ThirdFramePanel.add(label33);
        ThirdFramePanel.add(label34);
        ThirdFramePanel.add(previousBtn);
        
        cardPanel.add(FirstFramePanel, "1");
        cardPanel.add(SecondFramePanel, "2");
        cardPanel.add(ThirdFramePanel, "3");
        
        
        // for check
        
        nextBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if (currentCard < 3) {
                    currentCard += 1;
                    cl.show(cardPanel, "" + (currentCard));
                }
            }
        });
        
        previousBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if (currentCard > 1) {
                    currentCard -= 1;
                    cl.show(cardPanel, "" + (currentCard));
                }
            }
        });
        
        
        
             
        getContentPane().add(FirstFramePanel);
        
        
   
    }
    

 
 public static void main(String[] args) {
 
     WizardDisplay wizard = new WizardDisplay();
        wizard.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        wizard.setVisible(true); 
  
 }

}


