java applet program

cashier system

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 2964 Views - Last Post: 04 August 2007 - 12:47 PM Rate Topic: -----

#1 zedenaka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 07

java applet program

Post icon  Posted 02 August 2007 - 04:36 AM

guys i need some help regarding my program. you see the program runs but the problem is when it comes to the computation part or the "OK" & the "RESET" button it wont work. i'm not well known to java since its just a new topic for our class. here is the code.....

kindly tell me whats wrong in simple laymans term....

together with this is a snapshot of the output program. kindly look at the thumbnail.....

plssssssssss..........

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class mp2f extends Applet implements ActionListener,ItemListener

{
	int a;
	
	Label booksLbl = new Label("Books Available:");	
	Checkbox hpBox = new Checkbox("Harry Potter",false);
	Checkbox lotrBox = new Checkbox("Lord of the Rings",false);
	Checkbox aiwBox = new Checkbox("Alice in Wonderland",false);
	Checkbox pBox = new Checkbox("Prince",false);

	Label qtyLbl = new Label("Quantity");
	TextField qty1Txt = new TextField(10);
	TextField qty2Txt = new TextField(10);
	TextField qty3Txt = new TextField(10);
	TextField qty4Txt = new TextField(10);

	Label upLbl = new Label("Unit Price:");
	Label up1Lbl = new Label("P 1500");
	Label up2Lbl = new Label("P 1000");
	Label up3Lbl = new Label("P 800");
	Label up4Lbl = new Label("P 1600");

	Label tpLbl = new Label("Total Price");
	Label tp1Lbl = new Label("P");
	Label tp2Lbl = new Label("P");
	Label tp3Lbl = new Label("P");
	Label tp4Lbl = new Label("P");

	Label mopLbl = new Label("Mode of Payment:");
	CheckboxGroup optGroup = new CheckboxGroup();
	 Checkbox cash = new Checkbox("Cash",false,optGroup);
		Checkbox twop = new Checkbox("2 Payments(10%)",false,optGroup);
	 Checkbox threep = new Checkbox("3 Payments(20%)",false,optGroup);

	Label tqLbl = new Label("Total Quantity:");

	Label priceLbl = new Label("Price:");

	Label interestLbl = new Label("Interest:");

	Label taLbl = new Label("Total Amount:");	

	Button okButton = new Button("OK");

	 Button resetButton = new Button("RESET");
		
	 
	 public void init()

	 {

	add(booksLbl);
	add(hpBox);
	hpBox.addItemListener(this);
	add(lotrBox);
	lotrBox.addItemListener(this);
	add(aiwBox);
	aiwBox.addItemListener(this);
	add(pBox);
	pBox.addItemListener(this);

	add(qtyLbl);
	add(qty1Txt);	
	add(qty2Txt);
	add(qty3Txt);
	add(qty4Txt);

	add(upLbl);
	add(up1Lbl);
	add(up2Lbl);
	add(up3Lbl);
	add(up4Lbl);

	add(tpLbl);
	add(tp1Lbl);
	add(tp2Lbl);
	add(tp3Lbl);
	add(tp4Lbl);

	add(mopLbl);	
	add(cash);
	cash.addItemListener(this);
	add(twop);
	twop.addItemListener(this);
	add(threep);
	threep.addItemListener(this);
	
	add(tqLbl);

	add(priceLbl);

	add(interestLbl);

	add(okButton);
	okButton.addActionListener(this);
	add(resetButton);
	resetButton.addActionListener(this);	
		  

	 }

	 public void itemStateChanged(ItemEvent e)

	 {
	if(cash.getState())
	a=1;

	if(twop.getState())
	a=2;

	if(threep.getState())
	a=3;
	 }

 

	 public void actionPerformed(ActionEvent e)

	 {
	String arg;
	
	int tq,price,up1=0,up2=0,up3=0,up4=0,qty1,qty2,qty3,qty4,tp1,tp2,tp3,tp4;
	double interest=0,ta;

	qty1=Integer.parseInt(qty1Txt.getText());	
	qty2=Integer.parseInt(qty2Txt.getText());
	qty3=Integer.parseInt(qty3Txt.getText());
	qty4=Integer.parseInt(qty4Txt.getText());

	tp1=Integer.parseInt(tp1Lbl.getText());
	tp2=Integer.parseInt(tp2Lbl.getText());
	tp3=Integer.parseInt(tp3Lbl.getText());
	tp4=Integer.parseInt(tp4Lbl.getText());	
	
	arg=e.getActionCommand();	

	if(arg=="OK")
	{

		up1=1500;
		tp1=qty1*up1;
		tp1Lbl.setText("P " +tp1);
		
		up2=1000;
		tp2=qty2*up2;	
		tp2Lbl.setText("P " +tp2);
		
		up3=800;
		tp3=qty3*up3;
		tp3Lbl.setText("P " +tp3);
		
		up4=1600;
		tp4=qty4*up4;			
		tp4Lbl.setText("P " +tp4);	
		

		if(cash.getState())
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);

		interestLbl.setText("Interest: 0");

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}
	
		if(twop.getState())
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);
	
		interest=(price) * 0.1;
		interestLbl.setText("Interest: "+interest);

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}

		if(threep.getState())
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);

		interest=(price) * 0.2;
		interestLbl.setText("Interest: "+interest);

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}
	}
	
	if(arg=="RESET")
		
	{
		hpBox.setState(false);
		lotrBox.setState(false);
		aiwBox.setState(false);
		pBox.setState(false);
		qty1Txt.setText(" ");
		qty2Txt.setText(" ");
		qty3Txt.setText(" ");
		qty4Txt.setText(" ");
		tp1Lbl.setText("P");
		tp2Lbl.setText("P");
		tp3Lbl.setText("P");
		tp4Lbl.setText("P");
		cash.setState(false);
		twop.setState(false);
		threep.setState(false);
		tqLbl.setText("Total Quantity:");
		priceLbl.setText("Price:");
		interestLbl.setText("Interest:");
		taLbl.setText("Total Amount:");
		
	}
	 }
}

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: java applet program

#2 Martyr2  Icon User is online

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,088
  • Joined: 18-April 07

Re: java applet program

Posted 02 August 2007 - 10:51 AM

Hi,

It took me a minute to investigate what you were doing and I traced it down to your actionPerformed and what you are attempting to do in there. First of all the following lines are bad...

tp1=Integer.parseInt(tp1Lbl.getText());
tp2=Integer.parseInt(tp2Lbl.getText());
tp3=Integer.parseInt(tp3Lbl.getText());
tp4=Integer.parseInt(tp4Lbl.getText());  



The reason why is because your labels contain the letter "P" which won't parse to an Int. Commenting these lines out will start making everything work again. Now we have to see how we can get this working as it was intended to.

Analyzing what you had in your OK if statement I noticed you set a variable like qty1 to null, and up1 to 1500. What do you think 1500 times null gives you? It nulls out. Leaving you with your label just showing "P". To confirm this, right after your equation setting tp1, set it to a standard integer like 5. Voila, you will see your label starts reading "P 5". So what you got to do is make sure you have some valid data in your equations and control those nulls! If you don't, they will kill you and your program faster than some mafia organization.

So fix those four lines I shown above and make sure your equations are free of invalid values like null and you will be on your way to a fully working program.
Was This Post Helpful? 0
  • +
  • -

#3 zedenaka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 07

Re: java applet program

Posted 02 August 2007 - 05:20 PM

ok... thank you very much for your help i'll try what you said...ty ty ty ty ty ty

i still have one problem/question.....
here is the code ive tried for the actionPerformed...
its working but the problem is lets say i inputed 1 as the quantity for my qty1,when is click the OK button the output for the
tp's all have values.the tp1 should only have the value which is 1500 cause i only inputed 1 so 1*1500=1500. but the other tp's have also a value. how can i solve this??? i'm confused....
lastly the button cash,twop * threep should be false when i click the reset button, but the selected button isn't blank which should be bucause i set it to false....
what is wrong with it???

public void actionPerformed(ActionEvent e)

	 {
	String arg;
	
	int tq,price,up1=1500,up2=1000,up3=800,up4=1600,qty1=1,qty2=1,qty3=1,qty4=1,tp1,tp2,tp3,tp4;
	double interest=0,ta;

	
	arg=e.getActionCommand();	

	if(arg=="OK")
	{

		tp1=qty1*up1;
		tp1Lbl.setText("P " +tp1);
		
		tp2=qty2*up2;	
		tp2Lbl.setText("P " +tp2);
		
		tp3=qty3*up3;
		tp3Lbl.setText("P " +tp3);
		
		tp4=qty4*up4;			
		tp4Lbl.setText("P " +tp4);	
		

		if(cash.getState())
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);

		interestLbl.setText("Interest: 0");

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}
	
		if(twop.getState())
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);
	
		interest=(price) * 0.1;
		interestLbl.setText("Interest: "+interest);

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}

		if(threep.getState())
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);

		interest=(price) * 0.2;
		interestLbl.setText("Interest: "+interest);

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}
	}
	
	if(arg=="RESET")
		
	{
		hpBox.setState(false);
		lotrBox.setState(false);
		aiwBox.setState(false);
		pBox.setState(false);
		qty1Txt.setText(" ");
		qty2Txt.setText(" ");
		qty3Txt.setText(" ");
		qty4Txt.setText(" ");
		tp1Lbl.setText("P");
		tp2Lbl.setText("P");
		tp3Lbl.setText("P");
		tp4Lbl.setText("P");
		cash.setState(false);
		twop.setState(false);
		threep.setState(false);
		tqLbl.setText("Total Quantity:");
		priceLbl.setText("Price:");
		interestLbl.setText("Interest:");
		taLbl.setText("Total Amount:");


This post has been edited by zedenaka: 02 August 2007 - 06:12 PM

Was This Post Helpful? 0
  • +
  • -

#4 Martyr2  Icon User is online

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,088
  • Joined: 18-April 07

Re: java applet program

Posted 02 August 2007 - 10:56 PM

Well of course they all have values, you are setting all of them in your OK statement there. You have one setting it for tp1Lbl and then another setting tp2Lbl etc. You will have to devise a system which will check if there is an entry in a text field, if so, do the calculation and put it into the right box. The program is doing exactly as you have instructed it to do.

When you press ok you are...


		tp1=qty1*up1;
		tp1Lbl.setText("P " +tp1); // Setting your first label
		
		tp2=qty2*up2;	
		tp2Lbl.setText("P " +tp2); // Setting your second label
		
		tp3=qty3*up3;
		tp3Lbl.setText("P " +tp3); // Setting your third label
		
		tp4=qty4*up4;			
		tp4Lbl.setText("P " +tp4); // Setting your fourth label



You will have to test for a value in each textfield and set the label if they entered a value, otherwise leave the label alone. That I think you can do on your own. I believe in you! :)
Was This Post Helpful? 0
  • +
  • -

#5 zedenaka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 07

Re: java applet program

Posted 03 August 2007 - 12:23 AM

will this work???

				if(hpBox.getState())//when i put a check then the tp1 will compute
		{
		tp1=qty1*up1;
		tp1Lbl.setText("P " +tp1);
		}
		
		if(lotrBox.getState())//when i put a check then the tp2 will compute
		{
		tp2=qty2*up2;	
		tp2Lbl.setText("P " +tp2);
		}
		if(aiwBox.getState())//when i put a check then the tp3 will compute
		{
		tp3=qty3*up3;
		tp3Lbl.setText("P " +tp3);
		}

		if(pBox.getState())//when i put a check then the tp4 will compute
		{
		tp4=qty4*up4;			
		tp4Lbl.setText("P " +tp4);	
		}



but i'm having 9 errors in this part....what's worng with it???
the error says....
*mp2f.java:165: variable tp1 might not have been initialized*
why is that so???

				if(a==1)//for the itemStateChanged
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);

		interestLbl.setText("Interest: 0");

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}
	
		if(a==2)//for the itemStateChanged
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);
		

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);
	
		interest=(price) * 0.1;
		interestLbl.setText("Interest: "+interest);

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}

		if(a==3)//for the itemStateChanged
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);

		interest=(price) * 0.2;
		interestLbl.setText("Interest: "+interest);

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}


Was This Post Helpful? 0
  • +
  • -

#6 zedenaka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 07

Re: java applet program

Posted 04 August 2007 - 07:20 AM

guys im desparate i cant seem to get it right pls i need help :blink:
Was This Post Helpful? 0
  • +
  • -

#7 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: java applet program

Posted 04 August 2007 - 07:23 AM

can you post the complete code you are trying to run at this moment?
Was This Post Helpful? 0
  • +
  • -

#8 zedenaka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 07

Re: java applet program

Posted 04 August 2007 - 07:26 AM

//.java code
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class mp2f extends Applet implements ActionListener,ItemListener

{
	int a;
	
	Label booksLbl = new Label("Books Available:");	
	Checkbox hpBox = new Checkbox("Harry Potter",false);
	Checkbox lotrBox = new Checkbox("Lord of the Rings",false);
	Checkbox aiwBox = new Checkbox("Alice in Wonderland",false);
	Checkbox pBox = new Checkbox("Prince",false);

	Label qtyLbl = new Label("Quantity");
	TextField qty1Txt = new TextField(10);
	TextField qty2Txt = new TextField(10);
	TextField qty3Txt = new TextField(10);
	TextField qty4Txt = new TextField(10);

	Label upLbl = new Label("Unit Price:");
	Label up1Lbl = new Label("P 1500");
	Label up2Lbl = new Label("P 1000");
	Label up3Lbl = new Label("P 800");
	Label up4Lbl = new Label("P 1600");

	Label tpLbl = new Label("Total Price");
	Label tp1Lbl = new Label("");
	Label tp2Lbl = new Label("");
	Label tp3Lbl = new Label("");
	Label tp4Lbl = new Label("");
	
	Label mopLbl = new Label("Mode of Payment:");
	CheckboxGroup optGroup = new CheckboxGroup();
	 Checkbox cash = new Checkbox("Cash",false,optGroup);
		Checkbox twop = new Checkbox("2 Payments(10%)",false,optGroup);
	 Checkbox threep = new Checkbox("3 Payments(20%)",false,optGroup);

	Label tqLbl = new Label("Total Quantity:");

	Label priceLbl = new Label("Price:");

	Label interestLbl = new Label("Interest:");

	Label taLbl = new Label("Total Amount:");	

	Button okButton = new Button("OK");

	 Button resetButton = new Button("RESET");
		
	 
	 public void init()

	 {

	add(booksLbl);
	add(hpBox);
	hpBox.addItemListener(this);
	add(lotrBox);
	lotrBox.addItemListener(this);
	add(aiwBox);
	aiwBox.addItemListener(this);
	add(pBox);
	pBox.addItemListener(this);

	add(qtyLbl);
	add(qty1Txt);	
	add(qty2Txt);
	add(qty3Txt);
	add(qty4Txt);

	add(upLbl);
	add(up1Lbl);
	add(up2Lbl);
	add(up3Lbl);
	add(up4Lbl);

	add(tpLbl);
	add(tp1Lbl);
	add(tp2Lbl);
	add(tp3Lbl);
	add(tp4Lbl);
	

	add(mopLbl);	
	add(cash);
	cash.addItemListener(this);
	add(twop);
	twop.addItemListener(this);
	add(threep);
	threep.addItemListener(this);
	
	add(tqLbl);

	add(priceLbl);

	add(interestLbl);

	add(okButton);
	okButton.addActionListener(this);
	add(resetButton);
	resetButton.addActionListener(this);	
		  

	 }

	 public void itemStateChanged(ItemEvent e)

	 {
	if(cash.getState())
	a=1;

	if(twop.getState())
	a=2;

	if(threep.getState())
	a=3;
	 }

 

	 public void actionPerformed(ActionEvent e)

	 {
	String arg;
	
	int tq,price,up1=1500,up2=1000,up3=800,up4=1600,qty1=1,qty2=1,qty3=1,qty4=1,tp1,tp2,tp3,tp4;
	double interest=0,ta;

	
	arg=e.getActionCommand();	

	if(arg=="OK")
	{
		if(hpBox.getState())
		{
		tp1=qty1*up1;
		tp1Lbl.setText("P " +tp1);
		}
		
		if(lotrBox.getState())
		{
		tp2=qty2*up2;	
		tp2Lbl.setText("P " +tp2);
		}

		if(aiwBox.getState())
		{
		tp3=qty3*up3;
		tp3Lbl.setText("P " +tp3);
		}

		if(pBox.getState())
		{
		tp4=qty4*up4;			
		tp4Lbl.setText("P " +tp4);	
		}

		if(a==1)
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);

		interestLbl.setText("Interest: 0");

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}
	
		if(a==2)
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);
		

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);
	
		interest=(price) * 0.1;
		interestLbl.setText("Interest: "+interest);

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}

		if(a==3)
		{
		tq=(qty1) + (qty2) + (qty3) + (qty4);
		tqLbl.setText("Total Quantity: "+tq);

		price=(tp1) + (tp2) + (tp4) + (tp4);
		priceLbl.setText("Price: "+price);

		interest=(price) * 0.2;
		interestLbl.setText("Interest: "+interest);

		ta=price+interest;
		taLbl.setText("Total Amount: "+ta);
		}
	}
	
	if(arg=="RESET")
		
	{
		hpBox.setState(false);
		lotrBox.setState(false);
		aiwBox.setState(false);
		pBox.setState(false);
		qty1Txt.setText(" ");
		qty2Txt.setText(" ");
		qty3Txt.setText(" ");
		qty4Txt.setText(" ");
		tp1Lbl.setText("P");
		tp2Lbl.setText("P");
		tp3Lbl.setText("P");
		tp4Lbl.setText("P");
		cash.setState(false);
		twop.setState(false);
		threep.setState(false);
		tqLbl.setText("Total Quantity:");
		priceLbl.setText("Price:");
		interestLbl.setText("Interest:");
		taLbl.setText("Total Amount:");
		
	}
	 }
}



//html code
<html>
<applet code="mp2f.class" height=600 width=150>
</applet>
</html>


This post has been edited by zedenaka: 04 August 2007 - 07:28 AM

Was This Post Helpful? 0
  • +
  • -

#9 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: java applet program

Posted 04 August 2007 - 07:34 AM

try to initialize them like:
tp1=0,tp2=0,tp3=0,tp4=0;
in the declaration line.


o and try to increase the width of the applet to let say 250

This post has been edited by PennyBoki: 04 August 2007 - 07:37 AM

Was This Post Helpful? 0
  • +
  • -

#10 zedenaka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 07

Re: java applet program

Posted 04 August 2007 - 08:04 AM

ive tried it but the the problem is in the total quantity(qty) which should be the total of the qty1,qty2,qty3,qty4.... when i input a number in any of the textbox the output is always 4 which should not be... the output should be the total numbers like 1+2+3=should be 6....

same with the price..... the output should be the total of what the i inputed in the qty's....

i've changed the width :^:

can you run it so you can see the output :)

by the way penny i'm would like to thank you for helping me always....
your like an angel God gave to me:)

do you use yahoo messenger.... i have an account there... can i add you?
here my email add and ym id.
michaelvictoriano@yahoo.com

This post has been edited by zedenaka: 04 August 2007 - 08:00 AM

Was This Post Helpful? 0
  • +
  • -

#11 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: java applet program

Posted 04 August 2007 - 08:26 AM

the tq is always 4 because qty1, qty2, qty3, qty4 are set to 1 and never change, so try to make them change.

Quote

by the way penny i'm would like to thank you for helping me always....
your like an angel God gave to me:)

I think you'll be very disappointed to know that I'm a male and those are pretty strong words but I don't play that game.
Was This Post Helpful? 0
  • +
  • -

#12 zedenaka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 07

Re: java applet program

Posted 04 August 2007 - 08:49 AM

well i've tried to best of knowledge and i can't seem to find a way of doing it right could you pls give me a hint..... can i parse the qty's to integer???
qty1=Integer.parseInt(qty1Txt.getText());
qty2=Integer.parseInt(qty2Txt.getText());
qty3=Integer.parseInt(qty3Txt.getText());
qty4=Integer.parseInt(qty4Txt.getText());




AND.........................



dude i know your male..... and those words i said are just a way of saying thanks to you cause you've been a big help for me.... you see I'm a Filipino and we filipinos always show respect and thanks to people who helps us.... let's just say im only paying my gratitude.... i'm just making friends with you... i hope i didn't offend you....

This post has been edited by zedenaka: 04 August 2007 - 08:54 AM

Was This Post Helpful? 0
  • +
  • -

#13 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: java applet program

Posted 04 August 2007 - 08:57 AM

View Postzedenaka, on 4 Aug, 2007 - 08:49 AM, said:

well i've tried to best of knowledge and i can't seem to find a way of doing it right could you pls give me a hint..... can i parse the qty's to integer???
qty1=Integer.parseInt(qty1Lbl.getText());
qty2=Integer.parseInt(qty2Lbl.getText());
qty3=Integer.parseInt(qty3Lbl.getText());
qty4=Integer.parseInt(qty4Lbl.getText());




AND.........................



dude i know your male..... and those words i said are just a way of saying thanks to you cause you've been a big help for me.... you see I'm a Filipino and we filipinos always show respect and thanks to people who helps us.... let's just say im only paying my gratitude.... i'm just making friends with you... i hope i didn't offend you....


well that's a good idea but you are parsing the labels shouldn't you be parsing the qty1Txt textfields?

And I'm not offended it was kind of a joke on my side :) and Filipinos are cool people ...
Was This Post Helpful? 0
  • +
  • -

#14 zedenaka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 07

Re: java applet program

Posted 04 August 2007 - 09:09 AM

my fault.... i've changed the Lbl's to Txt's.... hehhehe..... but the problem is when i click the ok button errors appears..

look at the thumbnail....

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#15 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: java applet program

Posted 04 August 2007 - 09:30 AM

the problem is that how can the parser parse empty string when it's expecting to parse a string into int.
Therefore define
if the text field is empty the set qty(the one that's empty) to 0;
else parse it;

this way it only works when the four fields are filled

This post has been edited by PennyBoki: 04 August 2007 - 09:31 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2