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

Thread: problem with printing to text area

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    16
    My Mood
    Stressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem with printing to text area

    I have created a gui which is supposed to print calculations in a text area, however nothing prints when I hit the run report button.

    This is the snippet of code I am using. I am very new to java and to programming, so any help would be appreciated.

    [code]
    int columns = 2;
    int rows = earnings.length;
    double totalTime = 0.00;
    double totalPayment = 0.00;
    double averageWages =0.00;
    double minWage =7.00;

    String report = new String();

    for (int j=0;j<columns;j++){
    for(int i=0;i<rows;i++){
    if (j==0){
    totalTime+= earnings[i][j];
    }
    else if(j==1){
    totalPayment+= earnings[i][j];
    }
    }
    }
    jTextArea1.append("\n\n");
    jTextArea1.append("Report of your wages to Date\n\n");
    jTextArea1.append("\n");

    if (earnings.length>0){
    averageWages = totalPayment/(totalTime/60);
    }
    //Displays in text area
    jTextArea1.append("Average Per Hour Wage $ " + averageWages + "\n");
    jTextArea1.append("\n\n");
    jTextArea1.append("Minimum Wage is currently $6.55");
    jTextArea1.append("\n\n");

    if(averageWages<minWage){

    jTextArea1.append("Your average wages per hour are below Average");

    }else if(averageWages>=minWage && averageWages<=minWage * 2.00){
    jTextArea1.append("Your average wages per hour are average");

    }else if(averageWages > minWage * 2.00){
    jTextArea1.append("Your average wages per hour are above Average");
    }
    jTextArea1.append("Total Minutes Spent Tutoring = " +totalTime + "\n");
    jTextArea1.append("Total Earnings = $ " +totalPayment+ "\n");
    //calculates average per hour wage

    jTextArea1.append(report);
    }
    [code]


  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: problem with printing to text area

    Is any of the code you have posted executing? Add some printlns that will show if the code is being executed.
    All the calls to append() are inside of if tests. Are any of the if tests true?
    Add some printlns to show the values of the variables that control the if statement.

    Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    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: problem with printing to text area

    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    Mar 2012
    Posts
    16
    My Mood
    Stressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: problem with printing to text area

    Yes, I posted both topics. Wasn't sure if they were the same thing or different problems.

  5. #5
    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: problem with printing to text area

    What about the questions I asked in post#2?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Updating a text area from a JtextField! HELP
    By Java Programmer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 22nd, 2012, 08:05 PM
  2. Text file to text area and Radiobuttons?
    By donaldmax in forum What's Wrong With My Code?
    Replies: 9
    Last Post: May 27th, 2011, 04:45 AM
  3. Display in a text area
    By susieferrari in forum Java Theory & Questions
    Replies: 21
    Last Post: March 22nd, 2011, 09:56 AM
  4. Jigloo help to produce a text area which only scrolls down
    By rtumatt in forum AWT / Java Swing
    Replies: 0
    Last Post: February 2nd, 2010, 06:09 PM
  5. Problem in implementing mortgage calculator
    By American Raptor in forum AWT / Java Swing
    Replies: 1
    Last Post: April 1st, 2009, 02:09 PM