Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: I need help! Urgent!

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation I need help! Urgent!

    im constructing a GUI Order System using java. After everything was set, i got this error :

    Exception in thread "main" java.lang.NullPointerException
    at java.awt.Container.addImpl(Container.java:1090)
    at java.awt.Container.add(Container.java:410)
    at GUI.<init>(GUI.java:264)
    at GUI.main(GUI.java:298)

    Process completed.

    Can any1 tell me wats wrong with my coding? Thank you. I separate this software into 2 .java file and they should be linked.

    GUI.java :

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class GUI extends JFrame implements ActionListener
    {
    	private JTabbedPane body;
    	private JPanel pEntry = new JPanel();
    	private JPanel pButton = new JPanel();
    	private JPanel pButton2 = new JPanel();
    	private JPanel pButton3 = new JPanel();
    	private JPanel pDisplay = new JPanel();
    	private JPanel pSearch = new JPanel();
    	private JPanel pBeer1 = new JPanel();
    	private JPanel pBeer2 = new JPanel();
    	private JPanel pBeer3 = new JPanel();
    	private JPanel pBeer4 = new JPanel();
    	private JPanel pBeer5 = new JPanel();
    	private int counter = 0;
    	private int counter2 = 0;
    	private JLabel lblTitle,lblID,lblName,lblbeer,lblbeer1,lblbeer2,lblbeer3,lblbeer4,lblbeer5;
    	private JLabel lblAmount;
    	private JLabel lblTitled,lblIDd,lblNamed,lblbeerd,lblbeer1d,lblbeer2d,lblbeer3d,lblbeer4d,lblbeer5d;
    	private JLabel lblAmountd;
    	private JLabel lblTitleR,lblIDR,lblNameR,lblbeerR,lblbeer1R,lblbeer2R,lblbeer3R,lblbeer4R,lblbeer5R;
    	private JLabel lblAmountR;
    	private JLabel lblTitle1,lblSearch,lblID1,lblName1,lblbeer1a,lblbeer11,lblbeer21,lblbeer31,lblbeer41,lblbeer51;
    	private JLabel lblAmount1;
    	private JLabel lblID2,lblName2,lblbeer2a,lblbeer12,lblbeer22,lblbeer32,lblbeer42,lblbeer52;
    	private JLabel lblAmount2;
    	private JLabel lblBlank,lblBlank2,lblBlank3;
    	private JTextField txtID,txtName,txtSearch,txtBQty1,txtBQty2,txtBQty3,txtBQty4,txtBQty5;
    	private JButton btnReset,btnSave,btnPrevious,btnNext,btnDisplay,btnSearch;
    	String choice;
    	private boolean flag,flag2=false,flag3=false;
    	Order[]orderRec;
    	public GUI()
    	{
    		super("Order");
    		body = new JTabbedPane();
    		Font customFont = new Font("Arial Black",Font.PLAIN,20);
    		Font customFont2 = new Font("Arial",Font.BOLD,12);
    		Color customBlue = new Color(50,150,255);
    		Color customRed = new Color(255,150,150);
    		Color customYellow = new Color(255,200,100);
    		Color customGray = new Color(230,230,230);
     
    	lblTitle = new JLabel("ORDER");
    	lblID = new JLabel(counter+1 +". Customer No:");
    	lblName = new JLabel("Staff Name:");
    	lblbeer = new JLabel("Beverage:");
    	lblbeer1 = new JLabel("Starker in cup(RM30)");
    	lblbeer2 = new JLabel("Starker in barrel(RM300)");
    	lblbeer3 = new JLabel("Chivas(RM228)");
    	lblbeer4 = new JLabel("Johnny walker's(RM234)");
    	lblbeer5 = new JLabel("Bacardi(RM228)");
    	lblAmount = new JLabel("Amount:");
    	lblBlank = new JLabel();
    	lblBlank2 = new JLabel();
    	lblBlank3 = new JLabel();
    	lblTitled = new JLabel("RECORD");
    	lblIDd = new JLabel(counter2+1 +". Customer No.:");
    	lblNamed = new JLabel("Staff Name:");
    	lblbeerd = new JLabel("Beverage:");
    	lblbeer1d = new JLabel("Starker in cup(RM30)");
    	lblbeer2d = new JLabel("Starker in barrel(RM300)");
    	lblbeer3d = new JLabel("Chivas(RM228)");
    	lblbeer4d = new JLabel("Johnny walker's(RM234)");
    	lblbeer5d = new JLabel("Bacardi(RM228)");
    	lblAmount = new JLabel("Amount:");
    	lblIDR = new JLabel();
    	lblNameR = new JLabel();
    	lblbeerR = new JLabel();
    	lblbeer1R = new JLabel();
    	lblbeer2R = new JLabel();
    	lblbeer3R = new JLabel();
    	lblbeer4R = new JLabel();
    	lblbeer5R = new JLabel();
    	lblAmount = new JLabel();
    	lblTitle1 = new JLabel("SEARCH RECORD");
    	lblSearch = new JLabel("Search Customer No.");
    	lblName1 = new JLabel("Staff Name:");
    	lblbeer1a = new JLabel("Beverage:");
    	lblbeer11 = new JLabel("Starker in cup(RM30)");
    	lblbeer21 = new JLabel("Starker in barrel(RM300)");
    	lblbeer31 = new JLabel("Chivas(RM228)");
    	lblbeer41 = new JLabel("Johnny walker's(RM234)");
    	lblbeer51 = new JLabel("Bacardi(RM228)");
    	lblAmount1 = new JLabel("Amount:");
    	lblName2 = new JLabel();
    	lblbeer2a = new JLabel();
    	lblbeer12 = new JLabel();
    	lblbeer22 = new JLabel();
    	lblbeer32 = new JLabel();
    	lblbeer42 = new JLabel();
    	lblbeer52 = new JLabel();
    	lblAmount2 = new JLabel();
    	txtID = new JTextField("",20);
    	txtName = new JTextField("",20);
    	txtBQty1 = new JTextField("",20);
    	txtBQty2 = new JTextField("",20);
    	txtBQty3 = new JTextField("",20);
    	txtBQty4 = new JTextField("",20);
    	txtBQty5 = new JTextField("",20);
    	txtSearch = new JTextField("",20);
    	btnReset = new JButton("RESET");
    	btnReset.setFont(customFont2);
    	btnReset.setBackground(customBlue);
    	btnReset.setForeground(Color.white);
    	btnReset.addActionListener(this);
    	btnSave = new JButton("SAVE");
    	btnSave.setFont(customFont2);
    	btnSave.setBackground(customBlue);
    	btnSave.setForeground(Color.white);
    	btnSave.addActionListener(this);
    	//btnTotal = new JButton("TOTAL");
    	//btnTotal.setFont(customFont2);
    	//btnTotal.setBackground(customBlue);
    	//btnTotal.setForeground(Color.white);
    	//btnTotal.addActionListener(this);
    	//btnTotal = new JButton("TOTAL");
    	//btnTotal.setFont(customFont2);
    	//btnTotal.setBackground(customBlue);
    	//btnTotal.setForeground(Color.white);
    	//btnTotal.addActionListener(this);
    	btnNext = new JButton("NEXT");
    	btnNext.setFont(customFont2);
    	btnNext.setBackground(customBlue);
    	btnNext.setForeground(Color.white);
    	btnNext.addActionListener(this);
    	btnNext.setEnabled(false);
    	btnPrevious = new JButton("PREVIOUS");
    	btnPrevious.setFont(customFont2);
    	btnPrevious.setBackground(customBlue);
    	btnPrevious.setForeground(Color.white);
    	btnPrevious.addActionListener(this);
    	btnPrevious.setEnabled(false);
    	btnDisplay = new JButton("DISPLAY");
    	btnDisplay.setFont(customFont2);
    	btnDisplay.setBackground(customBlue);
    	btnDisplay.setForeground(Color.white);
    	btnDisplay.addActionListener(this);
    	btnDisplay.setEnabled(false);
    	btnSearch = new JButton("SEARCH");
    	btnSearch.setFont(customFont2);
    	btnSearch.setBackground(customBlue);
    	btnSearch.setForeground(Color.white);
    	btnSearch.addActionListener(this);
    	btnSearch.setEnabled(false);
    	String input = JOptionPane.showInputDialog("Enter number of items in the array");
    	int num = Integer.parseInt(input);
    	orderRec = new Order[num];
    	for(int j=0;j<orderRec.length;j++)
    	{
    		orderRec[j] = new Order();
    	}
    	pEntry.setLayout(new GridLayout(13,2,0,2));
    	lblTitle.setBackground(customBlue);
    	lblTitle.setForeground(Color.black);
    	lblTitle.setFont(customFont);
    	lblBlank.setBackground(customBlue);
    	pEntry.add(lblTitle);
    	pEntry.add(lblBlank);
    	pEntry.add(lblID);
    	pEntry.add(txtID);
    	pEntry.add(lblName);
    	pEntry.add(txtName);
    	pEntry.add(lblbeer);
    	pEntry.add(new JLabel());
    	pEntry.add(lblbeer1);
    	pBeer1.setLayout(new GridLayout(0,4,0,2));
    	pBeer1.add(txtBQty1);
    	pBeer1.add(new JLabel());
    	pBeer1.add(new JLabel());
    	pBeer1.add(new JLabel());
    	pEntry.add(pBeer1);
    	pEntry.add(lblbeer2);
    	pBeer2.setLayout(new GridLayout(0,4,0,2));
    	pBeer2.add(txtBQty2);
    	pBeer2.add(new JLabel());
    	pBeer2.add(new JLabel());
    	pBeer2.add(new JLabel());
    	pEntry.add(pBeer2);
    	pEntry.add(lblbeer3);
    	pBeer3.setLayout(new GridLayout(0,4,0,2));
    	pBeer3.add(txtBQty3);
    	pBeer3.add(new JLabel());
    	pBeer3.add(new JLabel());
    	pBeer3.add(new JLabel());
    	pEntry.add(pBeer3);
    	pEntry.add(lblbeer4);
    	pBeer4.setLayout(new GridLayout(0,4,0,2));
    	pBeer4.add(txtBQty4);
    	pBeer4.add(new JLabel());
    	pBeer4.add(new JLabel());
    	pBeer4.add(new JLabel());
    	pEntry.add(pBeer4);
    	pEntry.add(lblbeer5);
    	pBeer5.setLayout(new GridLayout(0,4,0,2));
    	pBeer5.add(txtBQty5);
    	pBeer5.add(new JLabel());
    	pBeer5.add(new JLabel());
    	pBeer5.add(new JLabel());
    	pEntry.add(pBeer5);
    	pEntry.add(lblAmount);
    	pEntry.add(new JLabel());
    	pEntry.add(new JLabel());
    	pEntry.add(new JLabel());
    	pButton.setLayout(new GridLayout(0,3,3,2));
    	pButton.add(new JLabel());
    	//pButton.add(btnTotal);
    	pButton.add(btnReset);
    	pButton.add(btnSave);
    	pEntry.add(pButton);
    	pEntry.add(new JLabel());
    	pEntry.add(new JLabel());
    	lblTitled.setBackground(customRed);
    	lblTitled.setForeground(Color.black);
    	lblTitled.setFont(customFont);
    	lblBlank2.setBackground(customRed);
    	pDisplay.setLayout(new GridLayout(15,2,0,2));
    	pDisplay.add(lblTitled);
    	pDisplay.add(lblBlank2);
    	pDisplay.add(lblIDd);
    	pDisplay.add(lblIDR);
    	pDisplay.add(lblNamed);
    	pDisplay.add(lblNameR);
    	pDisplay.add(lblbeer);
    	pDisplay.add(new JLabel());
    	pDisplay.add(lblbeer1d);
    	pDisplay.add(lblbeer1R);
    	pDisplay.add(lblbeer2d);
    	pDisplay.add(lblbeer2R);
    	pDisplay.add(lblbeer3d);
    	pDisplay.add(lblbeer3R);
    	pDisplay.add(lblbeer4d);
    	pDisplay.add(lblbeer4R);
    	pDisplay.add(lblbeer5d);
    	pDisplay.add(lblbeer5R);
    	pDisplay.add(lblAmount);
    	pDisplay.add(new JLabel());
    	pDisplay.add(new JLabel());
    	pDisplay.add(new JLabel());
    	pButton2.setLayout(new GridLayout(0,3,3,2));
    	pButton2.add(btnDisplay);
    	pButton2.add(btnPrevious);
    	pButton2.add(btnNext);
    	pDisplay.add(pButton2);
    	pDisplay.add(new JLabel());
    	pDisplay.add(new JLabel());
    	lblTitle1.setBackground(customYellow);
    	lblTitle1.setForeground(Color.black);
    	lblTitle1.setFont(customFont);
    	lblBlank3.setBackground(customYellow);
    	pSearch.setLayout(new GridLayout(15,2,0,2));
    	pSearch.add(lblTitle1);
    	pSearch.add(lblBlank3);
    	pSearch.add(lblSearch);
    	pButton3.setLayout(new GridLayout(0,2,2,2));
    	pButton3.add(txtSearch);
    	pButton3.add(btnSearch);
    	pSearch.add(pButton3);
    	pSearch.add(new JLabel());
    	pSearch.add(new JLabel());
    	pSearch.add(lblID1);
    	pSearch.add(lblID2);
    	pSearch.add(lblName1);
    	pSearch.add(lblName2);
    	pSearch.add(lblbeer1a);
    	pSearch.add(new JLabel());
    	pSearch.add(lblbeer11);
    	pSearch.add(lblbeer12);
    	pSearch.add(lblbeer21);
    	pSearch.add(lblbeer22);
    	pSearch.add(lblbeer31);
    	pSearch.add(lblbeer32);
    	pSearch.add(lblbeer41);
    	pSearch.add(lblbeer42);
    	pSearch.add(lblbeer51);
    	pSearch.add(lblbeer52);
    	pSearch.add(lblAmount1);
    	pSearch.add(lblAmount2);
    	pSearch.add(new JLabel());
    	pSearch.add(new JLabel());
    	body.addTab("RECORD",null,pEntry,"Entry Record");
    	body.addTab("DISPLAY",null,pEntry,"Display Record");
    	body.addTab("SEARCH",null,pEntry,"Search Record");
    	body.setBackgroundAt(0,customBlue);
    	body.setBackgroundAt(1,customRed);
    	body.setBackgroundAt(2,customYellow);
    	body.setBackground(customGray);
    	add(body);
    	setSize(580,430);
    	setVisible(true);
     
    	}//End of GUI
    public static void main(String[] args)throws AWTException
    {
    	GUI adm = new GUI();
    	adm.addWindowListener(
    		new WindowAdapter()
    		{
    			public void windowClosing(WindowEvent e)
    			{
    				System.exit(0);
    			}
    		}
    	);
    }//End of main
    public void actionPerformed(ActionEvent ae)
    {
    	if(ae.getSource()== btnReset)
    	{
    		Reset();
    	}
    	if(ae.getSource()== btnSave)
    	{
    		if(flag == false)
    		{
    			Validate();
    		}
    		if(flag == true)
    		{
    			Save();
    			Reset();
    			if(counter == 0)
    			{
    				btnNext.setEnabled(false);
    			}
    			else if(flag == true)
    			{
    				btnNext.setEnabled(true);
    			}
    			counter++;
    			if(counter == 1)
    			{
    				btnDisplay.setEnabled(true);
    				btnSearch.setEnabled(true);
    			}
    		}
    		lblID.setText(counter+1 +".Customer No. :");
    		if(counter >= orderRec.length)
    		{
    			counter = 0;
    			lblID.setText(counter+1 +".Customer No. :");
    		}
    		flag = false;
    	}
    	if(ae.getSource()== btnDisplay)
    	{
    	Display();
    	flag3 = true;
    	btnDisplay.setEnabled(false);
    	if(counter == 1)
    	{
    		btnNext.setEnabled(false);
    	}
    	if(counter != 1)
    	{
    		btnNext.setEnabled(true);
    	}
    	if(ae.getSource()== btnNext)
    	{
    		counter2++;
    		if(counter2 == (counter-1))
    		{
    			btnNext.setEnabled(false);
    		}
    		else
    		{
    			btnNext.setEnabled(true);
    		}
    		if(counter2 == 4)
    		{
    			btnNext.setEnabled(false);
    		}
    		btnPrevious.setEnabled(true);
    		lblID.setText(counter2+1 +".Customer No. :");
    		Display();
    	}
    	if(ae.getSource()== btnPrevious)
    	{
    		counter2--;
    		if(counter == 0)
    		{
    			btnPrevious.setEnabled(false);
    		}
    		else
    		{
    			btnPrevious.setEnabled(true);
    		}
    		btnNext.setEnabled(true);
    		lblID.setText(counter2+1 +".Customer No. :");
    		Display();
    	}
    	if(ae.getSource()== btnSearch)
    	{
    		Validate2();
    		Search();
    	}
    	}
    }// End of actionPerformed
     
    //---Reset---
    public void Reset()
    {
    	txtID.setText("");
    	txtName.setText("");
    	txtBQty1.setText("");
    	txtBQty2.setText("");
    	txtBQty3.setText("");
    	txtBQty4.setText("");
    	txtBQty5.setText("");
    }// End of reset
     
    //---Save Record---
    public void Save()
    {
    	String name,temp;
    	int customer,Quantity1,Quantity2,Quantity3,Quantity4,Quantity5;
    	String temp1,temp2,temp3,temp4,temp5;
     
    	temp1 = txtID.getText();
    	customer = Integer.parseInt(temp1);
    	orderRec[counter].setCustomerNo(customer);
    	name = txtName.getText();
    	orderRec[counter].setStaffName(name);
    	temp1 = txtBQty1.getText();
    	Quantity1 = Integer.parseInt(temp1);
    	orderRec[counter].setQuantityA(Quantity1);
    	temp2 = txtBQty2.getText();
    	Quantity2 = Integer.parseInt(temp2);
    	orderRec[counter].setQuantityB(Quantity2);
    	temp3 = txtBQty3.getText();
    	Quantity3 = Integer.parseInt(temp3);
    	orderRec[counter].setQuantityC(Quantity3);
    	temp4 = txtBQty4.getText();
    	Quantity4 = Integer.parseInt(temp4);
    	orderRec[counter].setQuantityD(Quantity4);
    	temp5 = txtBQty5.getText();
    	Quantity5 = Integer.parseInt(temp5);
    	orderRec[counter].setQuantityE(Quantity5);
    }// End of save
     
    //---Dispaly Record---
     public void Display()
     {
     	int temp2;
     	String temp3;
     	double temp4;
     	temp2 = orderRec[counter2].getCustomerNo();
     	temp3 = Integer.toString(temp2);
     	lblIDR.setText(temp3);
     	lblNameR.setText(orderRec[counter2].getStaffName());
     	temp2 = orderRec[counter2].getQuantityA();
     	temp3 = Integer.toString(temp2);
     	lblbeer1R.setText(temp3);
     	temp2 = orderRec[counter2].getQuantityB();
     	temp3 = Integer.toString(temp2);
     	lblbeer2R.setText(temp3);
     	temp2 = orderRec[counter2].getQuantityC();
     	temp3 = Integer.toString(temp2);
     	lblbeer3R.setText(temp3);
     	temp2 = orderRec[counter2].getQuantityD();
     	temp3 = Integer.toString(temp2);
     	lblbeer4R.setText(temp3);
     	temp2 = orderRec[counter2].getQuantityE();
     	temp3 = Integer.toString(temp2);
     	lblbeer5R.setText(temp3);
     
     
     }// End of Display
     
     //---Search Record---
     public void Search()
     {
     	String str, temp7;
     	int a,cust,temp6,temp8,count=0;
     	double temp9;
     
     	flag2 = true;
     	//int[] idArray = new int[orderRec.length];
     	str = txtSearch.getText();
     	a = Integer.parseInt(str);
     	for(int k=0;k<orderRec.length;k++)
     	{
     		//idArray[k] = orderRec[k].getCustomerNo();
     		if(orderRec[k].getCustomerNo() == a)
     		{
     			flag2=true;
     			temp6 = orderRec[k].getCustomerNo();
     			temp7 = Integer.toString(temp6);
     			lblIDR.setText(temp7);
     			lblNameR.setText(orderRec[k].getStaffName());
     			temp6 = orderRec[k].getQuantityA();
     			temp7 = Integer.toString(temp6);
     			lblbeer1R.setText(temp7);
     			temp6 = orderRec[k].getQuantityB();
     			temp7 = Integer.toString(temp6);
     			lblbeer2R.setText(temp7);
     			temp6 = orderRec[k].getQuantityC();
     			temp7 = Integer.toString(temp6);
     			lblbeer3R.setText(temp7);
     			temp6 = orderRec[k].getQuantityD();
     			temp7 = Integer.toString(temp6);
     			lblbeer4R.setText(temp7);
     			temp6 = orderRec[k].getQuantityE();
     			temp7 = Integer.toString(temp6);
     			lblbeer5R.setText(temp7);
     
     			break;
     		}
     		else if(!(orderRec[k].getCustomerNo() == a))
     		{
     			flag2 = false;
     		}
     	}
     	if(flag2 == false)
     	JOptionPane.showMessageDialog(this,"Record not found.");
     }// End of Search
     
     //---Validation Checking---
     public void Validate()throws ArithmeticException
     {
     	flag = false;
     	int c = 0;
     	try{
     		c =Integer.parseInt(txtID.getText());
     	}catch(NumberFormatException nfx){
     		JOptionPane.showMessageDialog(this,"Invalid Customer No.");
     	}
     	if(txtID.getText().equals("")||txtName.getText().equals("")){
     		JOptionPane.showMessageDialog(this,"Please fill in staff name and customer no.");
     	}
     	else if(!txtName.getText().matches("([a-zA-Z]+|[a-zA-Z]+\\s[a-zA-Z]+)*")){
     		JOptionPane.showMessageDialog(this,"Invalid Name");
     		txtName.requestFocus();
     	}
     	else{
     		flag = true;
     	}
     
     }// End of Validation
     
     //---Search Validation Checking---
     public void Validate2(){
     	if(txtSearch.getText().equals("")){
     		JOptionPane.showMessageDialog(this,"Please search ID");
     		txtSearch.requestFocus();
     	}
     }// End of Search Validation Checking
    }// End of class

    Order.java :
    public class Order
    {
    	//Instant variables
    	String staffName;
    	int customerNo;
    	int quantityA,quantityB,quantityC,quantityD,quantityE;
    	int amount;
     
     
     
    //Setter and Getter
    public void setStaffName(String sName)
    {
    	staffName = sName;
    }
    public String getStaffName()
    {
    	return staffName;
    }
    public void setCustomerNo(int CN)
    {
    	customerNo = CN;
    }
    public int getCustomerNo()
    {
    	return customerNo;
    }
    public void setQuantityA(int QtA)
    {
    	quantityA = QtA;
    }
    public int getQuantityA()
    {
    	return quantityA;
    }
    public void setQuantityB(int QtB)
    {
    	quantityB = QtB;
    }
    public int getQuantityB()
    {
    	return quantityB;
    }
    public void setQuantityC(int QtC)
    {
    	quantityC = QtC;
    }
    public int getQuantityC()
    {
    	return quantityC;
    }
    public void setQuantityD(int QtD)
    {
    	quantityD = QtD;
    }
    public int getQuantityD()
    {
    	return quantityD;
    }
    public void setQuantityE(int QtE)
    {
    	quantityE = QtE;
    }
    public int getQuantityE()
    {
    	return quantityE;
    }
    //Calculate amount
    }
    Last edited by Hyaki; June 20th, 2012 at 11:15 AM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: I need help! Urgent!

    Please read the link in my signature on asking questions the smart way, especially the bit about using meaningful titles as well as not mentioning your deadline or urgency (otherwise you come off as impatient and rude).

    Then follow the advice here: http://www.javaprogrammingforums.com...t-println.html

    If you're still stuck, then please narrow your problem down to an SSCCE by eliminating any extraneous code that does not directly attribute to the problem. An SSCCE should only be a few lines long.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I need help! Urgent!

    Exception in thread "main" java.lang.NullPointerException
    at java.awt.Container.addImpl(Container.java:1090)
    at java.awt.Container.add(Container.java:410)
    at GUI.<init>(GUI.java:264)
    What code is at line 264 in the GUI class? Do any of the variables on that line have a null value?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: I need help! Urgent!

    You posted the GUI class twice it looks like.
    Last edited by javapenguin; June 20th, 2012 at 11:05 AM.

  5. #5
    Junior Member
    Join Date
    Jun 2012
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: I need help! Urgent!

    Exception in thread "main" java.lang.NullPointerException
    at java.awt.Container.addImpl(Container.java:1090)
    at java.awt.Container.add(Container.java:410)
    at GUI.<init>(GUI.java:264)
    at GUI.main(GUI.java:298)
    There is some kind of error with your Container.
    At line 410 you add something that is broken. And I'm pretty sure you have made this at line 1090.
    298 is the error when you try to load the program. It has an error in the file, so it gives an error there.
    I don't know what the error on line 264 is though.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I need help! Urgent!

    @wuppy29 - You need to review what is shown in a stack trace.
    Line 298 in the main() method calls the GUI class's constructor
    Line 264 in the constructor calls the add() method of a container <<< This is the OPs code
    LIne 410 is in the Container class in the java.awt package <<< This was written by Sun
    Line 1090 is where the NPE exception was thrown. Probably because the argument to the add() method called on line 264 was null.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Urgent Need... !!!
    By Doyle Raymond in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: November 29th, 2011, 09:46 AM
  2. Need urgent help regarding java word wrap function.. URGENT
    By coldice in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 16th, 2011, 05:43 AM
  3. Urgent!!!!!!!!!!!!!!!!
    By dinesh03188 in forum JDBC & Databases
    Replies: 3
    Last Post: May 14th, 2010, 01:38 AM
  4. Urgent Help Please :)
    By Jamie94 in forum Algorithms & Recursion
    Replies: 0
    Last Post: May 12th, 2010, 06:34 AM
  5. Replies: 1
    Last Post: May 4th, 2009, 06:30 AM