Results 1 to 7 of 7
  1. #1
    javanew is offline Member
    Join Date
    Mar 2010
    Posts
    49
    Rep Power
    0

    Default Problem with JTEXTAREA

    Java Code:
    area.setText("\n" +c);
    area.setText("Number of lines"+x);
    it shows only the number of lines...
    how to make it show both,,,

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    11

    Default

    You need to use another JTextArea method: append(...)

    Java Code:
    area.setText("\n" + c);
    area.append("Number of lines " + x);
    ...

  3. #3
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    11

    Default

    Quote Originally Posted by curmudgeon View Post
    You need to use another JTextArea method: append(...)

    Java Code:
    area.setText("\n" + c);
    area.append("Number of lines " + x);
    ...
    I don;t think you can use appen on JTextArea.
    If not try it on TextArea (not JTextArea)

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default

    Quote Originally Posted by PhQ View Post
    I don;t think you can use appen on JTextArea.
    If not try it on TextArea (not JTextArea)
    Straight from the API documentation for the JTextArea class:

    void append(String str)
    Appends the given text to the end of the document.
    About that TextArea, that's an AWT thing; you don't want to go there.

    kind regards,

    Jos

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,313
    Blog Entries
    1
    Rep Power
    32

    Default

    Quote Originally Posted by PhQ View Post
    I don;t think you can use appen on JTextArea.
    If not try it on TextArea (not JTextArea)
    From what do you base this recommendation on?

    Myself, I agree with the other recommendations: it is fine to use append with JTextArea.

  6. #6
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    11

    Default

    Quote Originally Posted by Fubarable View Post
    From what do you base this recommendation on?

    Myself, I agree with the other recommendations: it is fine to use append with JTextArea.
    Oh, ok I thought that you can't append with JTextArea.

  7. #7
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    11

    Default

    Quote Originally Posted by javanew View Post
    Java Code:
    area.setText("\n" +c);
    area.setText("Number of lines"+x);
    it shows only the number of lines...
    how to make it show both,,,

    other solution

    Java Code:
    area.setText("\n" + c + "\n" + "Number of lines" + x);

Similar Threads

  1. JTextArea problem
    By javanew in forum AWT / Swing
    Replies: 2
    Last Post: 05-04-2010, 10:31 PM
  2. Replies: 12
    Last Post: 10-09-2009, 06:26 AM
  3. jfilechooser and jtextarea problem
    By kostinio in forum AWT / Swing
    Replies: 7
    Last Post: 10-07-2009, 08:46 AM
  4. Jtextarea Content Display Problem
    By REVANSIDDHA in forum Advanced Java
    Replies: 1
    Last Post: 03-31-2009, 06:53 PM
  5. Replies: 0
    Last Post: 07-17-2007, 03:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •