Re: New line in a JTextArea (student learning here)



Sandy wrote:

On Jan 28, 2:55 pm, Knute Johnson <nos...@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

Sandy wrote:

How does one append to a JTextArea in such a way to tell it that you
want this on a new line?

Thanks.JTextArea ta = new JTextArea();

ta.append("I want a new line at the end\n");

--

Knute Johnson
email s/nospam/knute/


Thanks. Makes perfect sense, just like a console app with C or C++. (Don't know why I didn't think of that! DOH!)

Just don't forget the "\n" *newline character* at the end of every line or else you'll end up with JTA-diahrea. I made this mistake myself once and had a devil of a time trying to figure it out.

Hey.... does it work different on Windows than on Unix? Is the new-line character represented differently on a different platform?
.