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 8 of 8

Thread: adding numbers in table

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

    Default adding numbers in table

    java.jpg

    hello . can somebody help me how can I add the numbers in quantity where it will automatically put in total?
    im using netbeans.

    just want the codes for how to add the listed quantity? hope you can help me


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: adding numbers in table

    What have you tried?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: adding numbers in table

    i tried this
    jLabel8.setText(String.valueOf(Double.parseDouble( txtQuantity.getText()) + Double.parseDouble(txtQuantity.getText())));

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: adding numbers in table

    What was the results?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: adding numbers in table

    i tried this
    if(txtQuantity.getText().equals("")){
    txtAmount.setText("");
    }
    else {
    txtAmount.setText(String.valueOf(Double.parseDoubl e(txtQuantity.getText()) * 250));
    but the Amount keeps changing into the quantity im putting it must be the sum of quantity

    --- Update ---

    it should be like this . First, I will put quantity: 12 then the amount will be 250 * 12 = 3000 , but when i change it in any number example 124 the amount change but total must be 124 + 12 = 136 so i want it like that hope you understand my grammar is not good

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: adding numbers in table

    If you want the total to be updated every time one of the values used to compute the total is changed, you will need to use a listener that can detect the change and recompute the total after the change is made.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Oct 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: adding numbers in table

    hmmm.

    what i mean is every time i input quantity it will keep adding and getting the sum. so that i can use that total in exchange for txtAmount.setText(String.valueOf(Double.parseDoubl e(*txtQuantity--this should be replace by the TotalQty*.getText()) * 250));

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: adding numbers in table

    Can you make a small, simple program that compiles, executes and shows the problem?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. adding 2 random numbers using multi threading
    By namso1902 in forum Threads
    Replies: 1
    Last Post: August 13th, 2013, 01:46 PM
  2. Adding odd numbers from 1 to 15
    By kcassar in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 9th, 2013, 07:24 AM
  3. Adding Fixed Point Numbers
    By Proletariat in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 14th, 2012, 10:00 AM
  4. Adding Big Numbers
    By hoiberg in forum Java Theory & Questions
    Replies: 5
    Last Post: December 16th, 2010, 08:44 AM
  5. adding up odd and even numbers
    By darlinho in forum What's Wrong With My Code?
    Replies: 10
    Last Post: September 30th, 2010, 03:28 PM