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

Thread: How to print to textarea? really no idea.

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to print to textarea? really no idea.

    Im pretty new to this programming so forgive me if i make any mistakes. Im making a little program with NetBeans, only now i have to add something which i really dont know how to do.

    I've made a little program with which you can calculate your interest. You have three jTextFields:

    1.Your starting amount of money.
    2.The percentage of interest you're dealing with.
    3.The amount of years you want to calculate.

    So further i have a jButton which contains the most of my code.

    double inputNumberInterest = Double.parseDouble(interest.getText());
        double inputNumberMoney = Double.parseDouble(money.getText());
        int inputNumberYears = Integer.parseInt(years.getText());
        DecimalFormat decimaal = new DecimalFormat("#,###.##");
     
        double result = inputNumberMoney * Math.pow(inputNumberInterest / 100 + 1,    inputNumberYears);
     
        this.reply.setText("" + decimaal.format(result);

    So this code prints the end result of the calculation. Now what my question is, I want to years in between to be printed also in a textArea. For example the user of this program enters 5, as years of interest. I want the 1st, 2nd, 3rd and 4th to be printed in a textArea. And the 5th year as it is now printed in a jTextField as i already have.

    Does anyone know how to do this?

    I hope to hear from you soon.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to print to textarea? really no idea.

    Use append() to add multiple lines of text, one after the other, in a JTextArea.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to print to textarea? really no idea.

    Can you explain that please? Because i really dont have a clue what to do

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to print to textarea? really no idea.

    Now what my question is, I want to years in between to be printed also in a textArea. For example the user of this program enters 5, as years of interest. I want the 1st, 2nd, 3rd and 4th to be printed in a textArea. And the 5th year as it is now printed in a jTextField as i already have.
    Show an example of how you imagine what you've described should look. To include multiple items in a single String object, use the concatenation operator, '+', e.g. "this" + "that" = "thisthat".

Similar Threads

  1. Replies: 7
    Last Post: March 29th, 2013, 07:38 AM
  2. How to clear the textArea?
    By dynamix24 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 25th, 2013, 08:46 AM
  3. Replies: 1
    Last Post: December 3rd, 2012, 02:35 PM
  4. Print table need some idea
    By Anc in forum AWT / Java Swing
    Replies: 0
    Last Post: May 30th, 2012, 09:31 AM
  5. [SOLVED] TextArea Not Setting size?
    By Java Programmer in forum AWT / Java Swing
    Replies: 4
    Last Post: January 22nd, 2012, 11:52 AM