What do these errors mean?
im new to java..

Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl<Container.java:1041>
at java.awt.Container.add<Container.java:365>
at OptionWindow.<init><OptionWindow.java:63>
at OptionWindow.main<OptionWindow.java:182>

please help

Recommended Answers

All 11 Replies

This is the first class of my code

/**
*Teacher Ref-ICS3USept.2010
*ICS3U Computer Programming
*September 2010
*Java Template: Save as Template.java
*Program description: This is a template you will be using every time you create a new java application!
**/

import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ISUmessdup extends JFrame
{

private static final int WIDTH=800;
private static final int HEIGHT=600;
private JLabel salesL,returninL,srtiL, openingstockL,purchL, retunoutL, headingL,carriageinL, closingstockL,costofgoodssoldL,grossprofitL,elecL,telephoneL,carriageoutwardL,waterL,expensetotalL,netproflossL;
private JLabel directmaterialsL, openingL,ospL, purchasesL, closingL, directlabL,patentfeeL,primecostL,indirectwageL,heatnlightL,insuranceL,genexpenseL,depreciationL,exptotL,pcexptotL,openingwrkL,closingwrkL,totwrkinprogL,gproducedL,factprofL,tplL,totworkinprogL;
private JTextField directmaterialsTF, openingTF,exptotTF, purchasesTF,ospTF, closingTF,pcexptotTF, directlabTF,totworkinprogTF,patentfeeTF,indirectwageTF,heatnlightTF,insuranceTF,genexpenseTF,depreciationTF,openingwrkTF,closingwrkTF,totwrkinprogTF,gproducedTF,factprofTF,tplTF,primecostTF;
private JTextField salesTF,returninTF,srtiTF, openingstockTF,purchTF, retunoutTF, carriageinTF, closingstockTF,costofgoodssoldTF,grossprofitTF,elecTF,telephoneTF,carriageoutwardTF,waterTF,expensetotalTF,netproflossTF;
private JButton calculateB, exitB,tplB;
private CalculateButtonHandler cbHandler;
private ExitButtonHandler ebHandler;
private TradingAccountHandler tbHandler;





public ISUmessdup()
{

openingL=new JLabel("Opening Stock: \n",SwingConstants.RIGHT);
purchasesL=new JLabel("Purchases: \n",SwingConstants.RIGHT);
ospL=new JLabel("---\n",SwingConstants.RIGHT);
closingL=new JLabel("Closing Stock: \n",SwingConstants.RIGHT);
directmaterialsL=new JLabel("---\n",SwingConstants.RIGHT);
directlabL=new JLabel("Direct Labour: \n",SwingConstants.RIGHT);
patentfeeL=new JLabel("Patent Fees: \n",SwingConstants.RIGHT);
primecostL=new JLabel("Prime Cost: \n",SwingConstants.RIGHT);
indirectwageL=new JLabel("Indirect Wages: \n",SwingConstants.RIGHT);
heatnlightL=new JLabel("Heating & Lighting: \n",SwingConstants.RIGHT);
insuranceL=new JLabel("Insurance: \n",SwingConstants.RIGHT);
genexpenseL=new JLabel("General Expenses: \n",SwingConstants.RIGHT);
depreciationL=new JLabel("Depreciation: ",SwingConstants.RIGHT);
exptotL=new JLabel("TOTAL EXPENSES: \n",SwingConstants.RIGHT);
pcexptotL=new JLabel("PCEXPTOT\n",SwingConstants.RIGHT);
openingwrkL=new JLabel("Opeining Work in Progress: \n",SwingConstants.RIGHT);
closingwrkL=new JLabel("Closing Work In Progress: ",SwingConstants.RIGHT);
totworkinprogL=new JLabel("TOTAL WORK IN PROGRESS\n",SwingConstants.RIGHT);
gproducedL=new JLabel("Factory Cost Of Goods Produced: \n",SwingConstants.RIGHT);
factprofL=new JLabel("Factory Profit (10 %): \n",SwingConstants.RIGHT);
tplL=new JLabel("Transferred to T P & L: \n",SwingConstants.RIGHT);


openingTF=new JTextField(10);
purchasesTF=new JTextField(10);
ospTF=new JTextField(10);
closingTF=new JTextField(10);
directmaterialsTF=new JTextField(10);
directlabTF=new JTextField(10);
patentfeeTF=new JTextField(10);
primecostTF=new JTextField(10);
indirectwageTF=new JTextField(10);
heatnlightTF=new JTextField(10);
insuranceTF=new JTextField(10);
genexpenseTF=new JTextField(10);
depreciationTF=new JTextField(10);
exptotTF=new JTextField(10);
pcexptotTF=new JTextField(10);
openingwrkTF=new JTextField(10);
closingwrkTF=new JTextField(10);
totworkinprogTF=new JTextField(10);
gproducedTF=new JTextField(10);
factprofTF=new JTextField(10);
tplTF=new JTextField(10);

calculateB=new JButton("Calculate");
cbHandler=new CalculateButtonHandler();
calculateB.addActionListener(cbHandler);

tplB=new JButton("Goto Trading Account");
tbHandler=new TradingAccountHandler();
tplB.addActionListener(tbHandler);

exitB=new JButton("Exit");
ebHandler=new ExitButtonHandler();
exitB.addActionListener(ebHandler);

setTitle("Manufacturing Account");

Container pane=getContentPane();
pane.setLayout(new GridLayout(28,1));

pane.add(openingL);
pane.add(openingTF);
pane.add(purchasesL);
pane.add(purchasesTF);
pane.add(closingL);
pane.add(closingTF);
pane.add(ospL);
pane.add(ospTF);
pane.add(directmaterialsL);
pane.add(directmaterialsTF);
pane.add(directlabL);
pane.add(directlabTF);
pane.add(patentfeeL);
pane.add(patentfeeTF);
pane.add(primecostL);
pane.add(primecostTF);
pane.add(indirectwageL);
pane.add(indirectwageTF);
pane.add(heatnlightL);
pane.add(heatnlightTF);
pane.add(insuranceL);
pane.add(insuranceTF);
pane.add(genexpenseL);
pane.add(genexpenseTF);
pane.add(depreciationL);
pane.add(depreciationTF);
pane.add(exptotL);
pane.add(exptotTF);
pane.add(pcexptotL);
pane.add(pcexptotTF);
pane.add(openingwrkL);
pane.add(openingwrkTF);
pane.add(closingwrkL);
pane.add(closingwrkTF);
pane.add(totworkinprogL);
pane.add(totworkinprogTF);
pane.add(gproducedL);
pane.add(gproducedTF);
pane.add(factprofL);
pane.add(factprofTF);
pane.add(tplL);
pane.add(tplTF);
pane.add(calculateB);
pane.add(tplB);
pane.add(exitB);

//Enter panes for trading account

setSize(WIDTH,HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}

private class CalculateButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
double opening,purchases,depreciation,exptot,pcexptot,openingwrk,closingwrk,totworkinprog,gproduced,factprof,tpl,closing,osp,directmaterials,directlab,patentfee, primecost,indirectwage,heatnlight,insurance,genexpense;

opening=Double.parseDouble(openingTF.getText());
purchases=Double.parseDouble(purchasesTF.getText());
closing=Double.parseDouble(closingTF.getText());
directlab=Double.parseDouble(directlabTF.getText());
patentfee=Double.parseDouble(patentfeeTF.getText());
heatnlight=Double.parseDouble(heatnlightTF.getText());
insurance=Double.parseDouble(insuranceTF.getText());
indirectwage=Double.parseDouble(indirectwageTF.getText());
genexpense=Double.parseDouble(genexpenseTF.getText());
depreciation=Double.parseDouble(depreciationTF.getText());
openingwrk=Double.parseDouble(openingwrkTF.getText());
closingwrk=Double.parseDouble(closingwrkTF.getText());
osp=opening+purchases;
directmaterials=osp-closing;
primecost=directmaterials+directlab+patentfee;
exptot=heatnlight+insurance+indirectwage+genexpense+depreciation;
pcexptot=primecost+exptot;
totworkinprog=openingwrk-closingwrk;
gproduced=pcexptot+totworkinprog;
factprof=gproduced*0.1;
tpl=factprof+gproduced;

ospTF.setText(" "+osp);
directmaterialsTF.setText(" "+directmaterials);
primecostTF.setText(" "+primecost);
exptotTF.setText(" "+exptot);
pcexptotTF.setText(" "+pcexptot);
totworkinprogTF.setText(" "+totworkinprog);
gproducedTF.setText(" "+gproduced);
factprofTF.setText(" "+factprof);
tplTF.setText(" "+tpl);
}
}
/**


**/

private class ExitButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}

private class TradingAccountHandler implements ActionListener
{

 public void actionPerformed(ActionEvent e)
 {

        if(e.getSource()==tplB)
        {
JOptionPane.showMessageDialog(null, "Trading Profit and Loss Account ");

OptionWindow tpl=new OptionWindow();

tpl.show();

		}
	}


}



	public static void main(String[]args)
		{
			ISUmessdup rectObject=new ISUmessdup();

	}		 
}

This is the class that is called- When i run this it gives me the errors mentioned in my first post

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

public class OptionWindow extends JFrame implements ActionListener
{



	private JLabel salesL,returninL,srtiL, openingstockL,purchL, retunoutL, headingL,carriageinL, closingstockL,costofgoodssoldL,grossprofitL,elecL,telephoneL,carriageoutwardL,waterL,expensetotalL,netproflossL;
	private JTextField salesTF,returninTF,srtiTF, openingstockTF,purchTF, retunoutTF, carriageinTF, closingstockTF,costofgoodssoldTF,grossprofitTF,elecTF,telephoneTF,carriageoutwardTF,waterTF,expensetotalTF,netproflossTF;
	private CalculateButtonHandlerTpl cbtHandler;
	private ExitButtonHandlerTpl ebtHandler;
	private JButton exitTB, calculateTB;



    public OptionWindow()
    {



		    setTitle("Trading Profit and Loss Account");

			salesL=new JLabel("Sales: \n",SwingConstants.RIGHT);
			returninL=new JLabel("Return Inwards: \n",SwingConstants.RIGHT);
			srtiL=new JLabel("---\n",SwingConstants.RIGHT);
			headingL=new JLabel("Cost of Goods Sold",SwingConstants.CENTER);
			openingstockL=new JLabel("Opening Stock: \n",SwingConstants.RIGHT);
			purchL=new JLabel("Purchases\n",SwingConstants.RIGHT);
			retunoutL=new JLabel("Return Outwards: \n",SwingConstants.RIGHT);
			carriageinL=new JLabel("Carriage Inwards: \n",SwingConstants.RIGHT);
			closingstockL=new JLabel("Closing Stock: \n",SwingConstants.RIGHT);
			costofgoodssoldL=new JLabel("---: \n",SwingConstants.RIGHT);
			grossprofitL=new JLabel("Gross Profit/Loss: \n",SwingConstants.RIGHT);
			elecL=new JLabel("Electricity: \n",SwingConstants.RIGHT);
			telephoneL=new JLabel("Telephone: \n",SwingConstants.RIGHT);
			carriageoutwardL=new JLabel("Carriage outwards: ",SwingConstants.RIGHT);
			waterL=new JLabel("Water: \n",SwingConstants.RIGHT);
			expensetotalL=new JLabel("TOTAL EXPENSES\n",SwingConstants.RIGHT);
			netproflossL=new JLabel("Net Profit/Loss: \n",SwingConstants.RIGHT);

		calculateTB=new JButton("Calculate");
		cbtHandler=new CalculateButtonHandlerTpl();
		calculateTB.addActionListener(cbtHandler);


		exitTB=new JButton("Exit");
		ebtHandler=new ExitButtonHandlerTpl();
		exitTB.addActionListener(ebtHandler);


		setTitle("Trading profit and loss account");

		Container pane=getContentPane();
		pane.setLayout(new GridLayout(28,1));

		pane.add(salesL);
		pane.add(salesTF);
		pane.add(returninL);
		pane.add(returninTF);
		pane.add(srtiL);
		pane.add(srtiTF);
		pane.add(headingL);

		pane.add(openingstockL);
		pane.add(openingstockTF);
		pane.add(purchL);
		pane.add(purchTF);
		pane.add(retunoutL);
		pane.add(retunoutTF);
		pane.add(carriageinL);
		pane.add(carriageinTF);
		pane.add(closingstockL);
		pane.add(closingstockTF);
		pane.add(costofgoodssoldL);
		pane.add(costofgoodssoldTF);
		pane.add(grossprofitL);
		pane.add(grossprofitTF);
		pane.add(elecL);
		pane.add(elecTF);
		pane.add(telephoneL);
		pane.add(telephoneTF);
		pane.add(carriageoutwardL);
		pane.add(carriageoutwardTF);
		pane.add(waterL);
		pane.add(waterTF);
		pane.add(expensetotalL);
		pane.add(expensetotalTF);
		pane.add(netproflossL);
		pane.add(netproflossTF);
		pane.add(calculateTB);
		pane.add(exitTB);



		setSize(WIDTH,HEIGHT);
		setVisible(true);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		}

		private class CalculateButtonHandlerTpl implements ActionListener
		{
			public void actionPerformed(ActionEvent e)
		{
			double sales=0.0;
			double o_stock=0.0;
			double p_s=0.0;
			double c_i=0.0;
			double c_stock=0.0;
			double r_o=0.0;
			double r_i=0.0;
			double cgs=0.0;
			double srti=0.0;
			double g_p=0.0;



			double c_o=0.0;
			double n_p=0.0;
			double exp=0.0;
			double electricity=0.0;
			double telephone=0.0;
			double carriageout=0.0;
			double water=0.0;



		sales=Double.parseDouble(salesTF.getText());
		r_i=Double.parseDouble(returninTF.getText());
		o_stock=Double.parseDouble(openingstockTF.getText());
		p_s=Double.parseDouble(purchTF.getText());
		r_o=Double.parseDouble(retunoutTF.getText());
		c_i=Double.parseDouble(carriageinTF.getText());
		c_stock=Double.parseDouble(closingstockTF.getText());
		electricity=Double.parseDouble(elecTF.getText());
		telephone=Double.parseDouble(telephoneTF.getText());
		carriageout=Double.parseDouble(carriageoutwardTF.getText());
		water=Double.parseDouble(waterTF.getText());


		srti=sales-r_i;
		cgs=o_stock+p_s-r_o+c_i-c_stock;
		g_p=srti-cgs;
		exp=telephone+electricity+c_o+water;
		n_p=g_p-exp;

		srtiTF.setText(" "+srti);
		costofgoodssoldTF.setText(" "+cgs);
		grossprofitTF.setText(" "+g_p);
		expensetotalTF.setText(" "+exp);
		netproflossTF.setText(" "+n_p);


			}
		}





		private class ExitButtonHandlerTpl implements ActionListener
		{
		public void actionPerformed(ActionEvent e)
		{
		System.exit(0);
		}
}

 public void actionPerformed(java.awt.event.ActionEvent e)
 {
 }

     public static void main(String[] args)
     {
         new OptionWindow();
 	}// TODO overwrite start(), stop() and destroy() methods
}

Hi there HDRG, I suggest very strongly that you look at the Javadoc for NullpointerException :

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/NullPointerException.html

The Javadoc API is an incredibly useful tool for any Java developer and should be your first port of call, especially for exceptions.
I see that each of your classes has a main() method, not sure why. But have you tried to run the main method of class ISUmessdup?

NullPointerException ("NPE") means either you are using a variable that hasn't been initialised, or you are using the result of a method that has returned null.
Search down the error listing until you find a reference to one of your classes, and that's where the error happened, in this case:
at OptionWindow.<init><OptionWindow.java:63>
<init> means during initialisation of a new instance (ie in the constructor), but 63 is the exact line number in file OptionWindow.java

I had a very quick look at the code, and it looks like you have initialised all the JLables. but not the JTextFields, so when you try to add a text field to the window, the variables holding the text fields are still null.

Just to add , how to read Exception stack trace to figure out what is wrong and where is wrong


Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl<Container.java:1041>
at java.awt.Container.add<Container.java:365>
at OptionWindow.<init><OptionWindow.java:63>
at OptionWindow.main<OptionWindow.java:182>

1) first useful information is Exception is in your "main" thread.
2) second useful informaiton is its while calling below method in Container.Java file at line 1041
java.awt.Container.addImpl<Container.java:1041>

the gotcha here is that this might be from java library or any third party library , so you would like to scroll down till the line it comes to your method and now you know at which line of your source code is creating this exception.

3) NullPointerException occurs when a) you call methods , access variables on an object which is null b) you try to synchronize on an object which is null

hope this helps.

I had forgotten to add all the JTextfields in OptionWindow.. Thanks for pointing that out..
But this part of the program still gives the message "java uses or overrides a deprecated API."

import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ISUmessdup extends JFrame
{

private static final int WIDTH=800;
private static final int HEIGHT=600;
private JLabel salesL,returninL,srtiL, openingstockL,purchL, retunoutL, headingL,carriageinL, closingstockL,costofgoodssoldL,grossprofitL,elecL,telephoneL,carriageoutwardL,waterL,expensetotalL,netproflossL;
private JLabel directmaterialsL, openingL,ospL, purchasesL, closingL, directlabL,patentfeeL,primecostL,indirectwageL,heatnlightL,insuranceL,genexpenseL,depreciationL,exptotL,pcexptotL,openingwrkL,closingwrkL,gproducedL,factprofL,tplL,totworkinprogL;
private JTextField directmaterialsTF, openingTF,exptotTF, purchasesTF,ospTF, closingTF,pcexptotTF, directlabTF,totworkinprogTF,patentfeeTF,indirectwageTF,heatnlightTF,insuranceTF,genexpenseTF,depreciationTF,openingwrkTF,closingwrkTF,totwrkinprogTF,gproducedTF,factprofTF,tplTF,primecostTF;

private JButton calculateB, exitB,tplB;
private CalculateButtonHandler cbHandler;
private ExitButtonHandler ebHandler;
private TradingAccountHandler tbHandler;

public ISUmessdup()
{

openingL=new JLabel("Opening Stock: \n",SwingConstants.RIGHT);
purchasesL=new JLabel("Purchases: \n",SwingConstants.RIGHT);
ospL=new JLabel("---\n",SwingConstants.RIGHT);
closingL=new JLabel("Closing Stock: \n",SwingConstants.RIGHT);
directmaterialsL=new JLabel("---\n",SwingConstants.RIGHT);
directlabL=new JLabel("Direct Labour: \n",SwingConstants.RIGHT);
patentfeeL=new JLabel("Patent Fees: \n",SwingConstants.RIGHT);
primecostL=new JLabel("Prime Cost: \n",SwingConstants.RIGHT);
indirectwageL=new JLabel("Indirect Wages: \n",SwingConstants.RIGHT);
heatnlightL=new JLabel("Heating & Lighting: \n",SwingConstants.RIGHT);
insuranceL=new JLabel("Insurance: \n",SwingConstants.RIGHT);
genexpenseL=new JLabel("General Expenses: \n",SwingConstants.RIGHT);
depreciationL=new JLabel("Depreciation: ",SwingConstants.RIGHT);
exptotL=new JLabel("TOTAL EXPENSES: \n",SwingConstants.RIGHT);
pcexptotL=new JLabel("PCEXPTOT\n",SwingConstants.RIGHT);
openingwrkL=new JLabel("Opeining Work in Progress: \n",SwingConstants.RIGHT);
closingwrkL=new JLabel("Closing Work In Progress: ",SwingConstants.RIGHT);
totworkinprogL=new JLabel("TOTAL WORK IN PROGRESS\n",SwingConstants.RIGHT);
gproducedL=new JLabel("Factory Cost Of Goods Produced: \n",SwingConstants.RIGHT);
factprofL=new JLabel("Factory Profit (10 %): \n",SwingConstants.RIGHT);
tplL=new JLabel("Transferred to T P & L: \n",SwingConstants.RIGHT);

//WdirectmaterialsTF, WopeningTF,exptotTF, WpurchasesTF,WospTF, WclosingTF,WpcexptotTF, WdirectlabTF,WtotworkinprogTF,WpatentfeeTF,WindirectwageTF,WheatnlightTF,WinsuranceTF,WgenexpenseTF,WdepreciationTF,WopeningwrkTF,WclosingwrkTF,totwrkinprogTF,gproducedTF,WfactprofTF,WtplTF,WprimecostTF;
openingTF=new JTextField(10);
purchasesTF=new JTextField(10);
ospTF=new JTextField(10);
closingTF=new JTextField(10);
directmaterialsTF=new JTextField(10);
directlabTF=new JTextField(10);
patentfeeTF=new JTextField(10);
primecostTF=new JTextField(10);
indirectwageTF=new JTextField(10);
heatnlightTF=new JTextField(10);
insuranceTF=new JTextField(10);
genexpenseTF=new JTextField(10);
depreciationTF=new JTextField(10);
exptotTF=new JTextField(10);
pcexptotTF=new JTextField(10);
openingwrkTF=new JTextField(10);
closingwrkTF=new JTextField(10);
totworkinprogTF=new JTextField(10);
gproducedTF=new JTextField(10);
factprofTF=new JTextField(10);
tplTF=new JTextField(10);



calculateB=new JButton("Calculate");
cbHandler=new CalculateButtonHandler();
calculateB.addActionListener(cbHandler);

tplB=new JButton("Goto Trading Account");
tbHandler=new TradingAccountHandler();
tplB.addActionListener(tbHandler);

exitB=new JButton("Exit");
ebHandler=new ExitButtonHandler();
exitB.addActionListener(ebHandler);

setTitle("Manufacturing Account");

Container pane=getContentPane();
pane.setLayout(new GridLayout(28,1));

pane.add(openingL);
pane.add(openingTF);
pane.add(purchasesL);
pane.add(purchasesTF);
pane.add(closingL);
pane.add(closingTF);
pane.add(ospL);
pane.add(ospTF);
pane.add(directmaterialsL);
pane.add(directmaterialsTF);
pane.add(directlabL);
pane.add(directlabTF);
pane.add(patentfeeL);
pane.add(patentfeeTF);
pane.add(primecostL);
pane.add(primecostTF);
pane.add(indirectwageL);
pane.add(indirectwageTF);
pane.add(heatnlightL);
pane.add(heatnlightTF);
pane.add(insuranceL);
pane.add(insuranceTF);
pane.add(genexpenseL);
pane.add(genexpenseTF);
pane.add(depreciationL);
pane.add(depreciationTF);
pane.add(exptotL);
pane.add(exptotTF);
pane.add(pcexptotL);
pane.add(pcexptotTF);
pane.add(openingwrkL);
pane.add(openingwrkTF);
pane.add(closingwrkL);
pane.add(closingwrkTF);
pane.add(totworkinprogL);
pane.add(totworkinprogTF);
pane.add(gproducedL);
pane.add(gproducedTF);
pane.add(factprofL);
pane.add(factprofTF);
pane.add(tplL);
pane.add(tplTF);
pane.add(calculateB);
pane.add(tplB);
pane.add(exitB);

setSize(WIDTH,HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}

private class CalculateButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
double opening,purchases,depreciation,exptot,pcexptot,openingwrk,closingwrk,totworkinprog,gproduced,factprof,tpl,closing,osp,directmaterials,directlab,patentfee, primecost,indirectwage,heatnlight,insurance,genexpense;

opening=Double.parseDouble(openingTF.getText());
purchases=Double.parseDouble(purchasesTF.getText());
closing=Double.parseDouble(closingTF.getText());
directlab=Double.parseDouble(directlabTF.getText());
patentfee=Double.parseDouble(patentfeeTF.getText());
heatnlight=Double.parseDouble(heatnlightTF.getText());
insurance=Double.parseDouble(insuranceTF.getText());
indirectwage=Double.parseDouble(indirectwageTF.getText());
genexpense=Double.parseDouble(genexpenseTF.getText());
depreciation=Double.parseDouble(depreciationTF.getText());
openingwrk=Double.parseDouble(openingwrkTF.getText());
closingwrk=Double.parseDouble(closingwrkTF.getText());
osp=opening+purchases;
directmaterials=osp-closing;
primecost=directmaterials+directlab+patentfee;
exptot=heatnlight+insurance+indirectwage+genexpense+depreciation;
pcexptot=primecost+exptot;
totworkinprog=openingwrk-closingwrk;
gproduced=pcexptot+totworkinprog;
factprof=gproduced*0.1;
tpl=factprof+gproduced;


ospTF.setText(" "+osp);
directmaterialsTF.setText(" "+directmaterials);
primecostTF.setText(" "+primecost);
exptotTF.setText(" "+exptot);
pcexptotTF.setText(" "+pcexptot);
totworkinprogTF.setText(" "+totworkinprog);
gproducedTF.setText(" "+gproduced);
factprofTF.setText(" "+factprof);
tplTF.setText(" "+tpl);
}
}
/**


**/

private class ExitButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}

private class TradingAccountHandler implements ActionListener
{

 public void actionPerformed(ActionEvent e)
 {

        if(e.getSource()==tplB)
        {
JOptionPane.showMessageDialog(null, "Trading Profit and Loss Account ");

OptionWindow tpl=new OptionWindow();

tpl.show();

		}
	}


}



	public static void main(String[]args)
		{
			ISUmessdup rectObject=new ISUmessdup();

	}


		 
}//end class

Read the whole of the error message - it tells you the line number where the error is found.
Deprecated means you have used something from an old version of Java that has been replaced by something better. Look at the method(s) you call on the relevant line. The JavaDoc API documentation will tell you how you should update your code

Thanks James.. oh yeah is there a way of making a text field only display output? because when you leave the text field blank, it gives an error message, there has to be a zero in it. so i was wondering if the text field could be output only..

Use a JLabel instead?

lol nvm i got it... what i meant was that a text field that only outputs calculated values. but prevents anything from being typed in that field. It was basically this:

expensetotalTF.setBorder(BorderFactory.createLoweredBevelBorder());
		    expensetotalTF.setEditable(false);

Thanx for Helping me Everyone..

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.