I have this error
--------------------Configuration: <Default>--------------------
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1041)
at java.awt.Container.add(Container.java:959)
at javax.swing.JFrame.addImpl(JFrame.java:540)
at java.awt.Container.add(Container.java:365)
at ticketReservation.<init>(ticketReservation.java:114)
at bookAngels.actionPerformed(bookAngels.java:163)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6267)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
...and i dont know what the problem is. Can u help me find it..

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class bookBatman extends JFrame implements ActionListener {

	private JLabel jlbName, jlbTime, jlbPic, jlbDate, jlbDescription, jlbAuthor, jlbDateProduce, jlbDirector, jlbActor, jlbRate, jlbNoOfTicket, jlbPrice;
	private JTextField jtfNoOfTicket;
	private JRadioButton jr1, jr2, jr3, jr4, jr5, jr6, jr7, jr8, jr9, jr10;
	private JButton jBook, jCancel;

	Font f = new Font("Times",Font.BOLD,30);

	public bookBatman () {


      	setLayout(null); //set LayoutManager

		// initialized the label
		jlbName = new JLabel ("Batman : The Dark Knight");
		jlbTime = new JLabel ("Time :");
		jlbPrice = new JLabel ("RM 12.00");
		jlbPic = new JLabel ();
		jlbPic.setIcon(new ImageIcon("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\Batman.jpg"));


		// add all the label on the frame
    	add(jlbName);
    	add(jlbPic);
    	add(jlbTime);
    	add(jlbPrice);


    	// set all the label positions
    	jlbName.setBounds(85, 78, 149, 18); //(int x, int y, int width, int height)
    	jlbPic.setBounds(74, 101, 180, 288);
    	jlbTime.setBounds(74, 400, 60, 18);
    	jlbPrice.setBounds (270, 477, 60, 18);


    	// initialized the textfield
   	 	jlbAuthor = new JLabel ("Author : Michael Bay");
   	 	jlbDateProduce = new JLabel ("Date : 12nd January 2011");
   	 	jlbDirector = new JLabel ("Director : Michael Bay, Michael Bay");
   	 	jlbActor = new JLabel ("Actor : Michael Bay, Michael Bay, Michael Bay, Michael Bay, Michael Bay and etc..");
   	 	jlbRate = new JLabel ("Movie Rate : 18 PG (Parental Guidance)");
   	 	jlbNoOfTicket = new JLabel ("Number of Ticket :");
   	 	jlbPrice = new JLabel ("RM 12.00");


		// add all the textfield on the frame
		add(jlbAuthor);
		add(jlbDateProduce);
		add(jlbDirector);
		add(jlbActor);
		add(jlbRate);
		add(jlbNoOfTicket);


		// set the textfield position
		jlbAuthor.setBounds (273, 102, 111, 18);
		jlbDateProduce.setBounds (273, 132, 114, 18);
		jlbDirector.setBounds (273, 162, 110, 18);
		jlbActor.setBounds (273, 192, 297, 18);
		jlbRate.setBounds (273, 222, 96, 18);
		jlbNoOfTicket.setBounds (77, 478, 150, 18);


		// initialize the Radio Button
		jr1 = new JRadioButton ("11.40 AM");
		jr2 = new JRadioButton ("12.00 PM");
		jr3 = new JRadioButton ("1.40 PM");
		jr4 = new JRadioButton ("3.40 PM");
		jr5 = new JRadioButton ("5.40 PM");
		jr6 = new JRadioButton ("7.00 PM");
		jr7 = new JRadioButton ("9.00 PM");
		jr8 = new JRadioButton ("10.40 PM");
		jr9 = new JRadioButton ("11.40 PM");
		jr10 = new JRadioButton ("12.40 AM");


		// add all the radion button
		add(jr1);
		add(jr2);
		add(jr3);
		add(jr4);
		add(jr5);
		add(jr6);
		add(jr7);
		add(jr8);
		add(jr9);
		add(jr10);


		// set the radion button positions
		jr1.setBounds (75, 423, 100, 24);
		jr2.setBounds (172, 423, 100, 24);
		jr3.setBounds (269, 423, 100, 24);
		jr4.setBounds (366, 423, 100, 24);
		jr5.setBounds (463, 423, 100, 24);
		jr6.setBounds (75, 447, 100, 24);
		jr7.setBounds (172, 447, 100, 24);
		jr8.setBounds (269, 447, 100, 24);
		jr9.setBounds (366, 447, 100, 24);
		jr10.setBounds (463, 447, 100, 24);


		// group the button
		ButtonGroup group = new ButtonGroup ();
		group.add(jr1);
		group.add(jr2);
		group.add(jr3);
		group.add(jr4);
		group.add(jr5);
		group.add(jr6);
		group.add(jr7);
		group.add(jr8);
		group.add(jr9);
		group.add(jr10);


		// initialize all the button
		jBook = new JButton ("Book Now");
		jCancel = new JButton ("Cancel");


		// add all the button
		add (jBook);
		add (jCancel);


		// set the button positions
		jBook.setBounds (285, 519, 93, 28);
		jCancel.setBounds (389, 519, 83, 28);


		// add actionlistener
		jBook.addActionListener (this);
		jCancel.addActionListener (this);


		// initialize all text field
		jtfNoOfTicket = new JTextField (15);


		// add all the text field
		add (jtfNoOfTicket);


		// set the text field positions
		jtfNoOfTicket.setBounds (200, 477, 56, 22);

			}

		public static void main (String [] args) {

			bookBatman frame = new bookBatman ();
   			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			frame.setTitle("Book Batman : The Dark Knight"); //set title of thewindow
			frame.setSize(800,600); //size of the window
			frame.setVisible(true); //visible the window
			frame.setLocationRelativeTo (null); //center the window

		}

		public void actionPerformed(ActionEvent e){
			if((e.getSource() == jBook)) {
				String Name = jtfName.getText();
				String Date = jlbDateProduce.getText();
				int Number = (Integer.parseInt(jtfNoOfTicket.getText().trim()));

				//Passing
				ticketReservation frame = new ticketReservation(Name, Date, String.valueOf (Number));
   				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.setTitle("Ticket Reservation"); //set title of thewindow
				frame.setSize(800,600); //size of the window
				frame.setVisible(true); //visible the window
				frame.setLocationRelativeTo (null); //center the window

				}

			if((e.getSource() == jCancel))  {

  				listOfMovies frame = new listOfMovies ();
   				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.setTitle("List of Movies"); //set title of thewindow
				frame.setSize(800,600); //size of the window
				frame.setVisible(true); //visible the window
				frame.setLocationRelativeTo (null); //center the window

				}
		}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ticketReservation extends JFrame implements ActionListener {

	private JLabel jlbWelcome, jlbReserved, jlbMovie, jlbDateProduce, jlbShowtime, jlbNoOfSeats, jlbPrice, jlbNoOfTicket;
	private JTextField jtfMovie, jtfDate, jtfShowtime, jtfNoOfSeats, jtfPrice, jtfNoOfTicket;
	private JButton jConfirm, jCancel;
//	private JRadioButton ButtonGroup;

	Font f=new Font("Times",Font.BOLD,30);
    //Font f1=new Font("Times",Font.BOLD,16);
    //Font f2=new Font("Times",Font.BOLD,12);

	public ticketReservation () {

		}

	public ticketReservation (String Name,String Date, String Number) {

		setLayout(null); //set LayoutManager

			jlbWelcome = new JLabel ("Ticket Reservation");
			add(jlbWelcome);
			jlbWelcome.setBounds(170,50,500,100);
    		jlbWelcome.setHorizontalAlignment(jlbWelcome.CENTER );
    		jlbWelcome.setFont(f);


    		// initialized the label
    		jlbMovie = new JLabel("Movie :");
    	//	jlbDate = new JLabel("Date :");
    		jlbShowtime = new JLabel("Showtime :");
   			jlbNoOfSeats = new JLabel("No of Seats :");
    		jlbPrice = new JLabel("Price :");
    		jlbNoOfTicket = new JLabel("No Of Tickets :");


    		// add all the label on the frame
    		add(jlbMovie);
    	//	add(jlbDate);
    		add(jlbShowtime);
    		add(jlbNoOfSeats);
    		add(jlbPrice);
    		add(jlbNoOfTicket);


    		// set Positions
    		jlbMovie.setBounds(300,140,100,20); //(int x, int y, int width, int height)
    	//	jlbDate.setBounds(300,180,100,20);
    		jlbShowtime.setBounds(300,220,100,20);
    		jlbNoOfSeats.setBounds(300,250,100,20);
    		jlbPrice.setBounds(300,280,100,20);
    		jlbNoOfTicket.setBounds(300,310,100,20);


    		// initialize the textfield with size
    	//	jtfMovie = new JTextField(15);
    	//	jtfDate = new JTextField(15);
    		jtfShowtime = new JTextField(15);
    		jtfNoOfSeats = new JTextField(15);
    		jtfPrice = new JTextField(15);
    	//	jtfNoOfTicket = new JTextField(15);


    		// add all the label on the frame
    	//	add(jtfMovie);
    	//	add(jtfDate);
    		add(jtfShowtime);
    		add(jtfNoOfSeats);
    		add(jtfPrice);
    	//	add(jtfNoOfTicket);


    		// set a particlar position on a frame
    //		jtfMovie.setBounds(400,140,100,20); //.setBounds (int x, int y, int width, int height)
    	//	jtfDate.setBounds(400,180,100,20);
    		jtfShowtime.setBounds(400,220,100,20);
    		jtfNoOfSeats.setBounds(400,250,100,20);
    		jtfPrice.setBounds(400,280,100,20);
    	//	jtfNoOfTicket.setBounds(400,320,100,20);


    		// add button
    		jConfirm = new JButton("Confirm");
    		jCancel = new JButton("Cancel");


    		// add tooltip in the buttons
    		jConfirm.setToolTipText("Click this button to Add record in the Database.");
    		jCancel.setToolTipText("Click this button to Save record in the Database.");


    		// add all the button on a frame
    		add(jConfirm);
    		add(jCancel);


    		// set a particular position on a Frame
    		jConfirm.setBounds(290,370,100,30);
    		jCancel.setBounds(400,370,100,30);


    		// register all the button
    		jConfirm.addActionListener(this);
    		jCancel.addActionListener(this);

			jlbMovie= new JLabel (Name);
			jtfNoOfTicket = new JTextField (Number);
			jlbDateProduce = new JLabel (Date);
//			ButtonGroup = new JRadioButton (group);

			add (jtfMovie);
			add (jtfNoOfTicket);
			add (jlbDateProduce);
//			add (ButtonGroup);

			jtfMovie.setBounds(400,140,100,20);
			jtfNoOfTicket.setBounds(400,320,100,20);
			jlbDateProduce.setBounds (300,180,300,20);
//			ButtonGroup.setBounds (300,180,300,20);

			jtfMovie.setEditable(false); //not editable
			jtfNoOfTicket.setEditable(false); //not editable
}



	public void actionPerformed(ActionEvent e) {

		if((e.getSource() == jCancel))  {

  				listOfMovies frame = new listOfMovies ();
   				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.setTitle("List of Movies"); //set title of thewindow
				frame.setSize(800,600); //size of the window
				frame.setVisible(true); //visible the window
				frame.setLocationRelativeTo (null); //center the window
			}

	}


	public static void main (String [] args) {

		ticketReservation frame=new ticketReservation();
   		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setTitle("Ticket Reservation"); //set title of thewindow
		frame.setSize(800,600); //size of the window
		frame.setVisible(true); //visible the window
		frame.setLocationRelativeTo (null); //center the window
	}
}

5-6 lines down in the stack we see

at ticketReservation.<init>(ticketReservation.java:114)
at bookAngels.actionPerformed(bookAngels.java:163)

the line numbers don't match the code you posted, so you need to look at the constructor for ticketReservation line 114 and see which variable is null.

Well since I had a lot of time on my hands :P , I studied every line of code, the problem looks to be on line 109 you have reinitialized the variable 'jlbMovie', while on line 119 you are setting the bounds for the text field 'jtfMovie' which has never been initialized, so is null.

I am guessing the O.P. intended to initialize 'jtfMovie' on line 109.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.