File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes line breaks in textfields? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "line breaks in textfields?" Watch "line breaks in textfields?" New topic

line breaks in textfields?

steve tang

Joined: Jun 12, 2005
Posts: 2
How can I make a line break in a textfield?
I want to make something like a list that requires line breaks and I want to add it to the end of a string

moveString += "(" + (k1 + 1) + "," + (k2 + 1) + ") " +\r\n; doesn't work

Timmy Marks
Ranch Hand

Joined: Dec 01, 2003
Posts: 226
Don't know if this will solve your problem, but the \n should be in quotes as well:

moveString += "(" + (k1 + 1) + "," + (k2 + 1) + ")\n";

You probably don't need the \r.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Are we talking about AWT, Swing, SWT, HTML or something different here?

Anyway, in most, if not all, of those, textfields can't show more than one line - you'll need a textarea for that.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: line breaks in textfields?
It's not a secret anymore!