aspose file tools*
The moose likes Beginning Java and the fly likes TextArea wrap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "TextArea wrap" Watch "TextArea wrap" New topic
Author

TextArea wrap

Sharada Kumaran
Greenhorn

Joined: May 23, 2001
Posts: 29
I am reading from a file , and appending to a TextArea/JTextArea. Right now, each line in the text area stretches on forever. Is there some property I can use to make my TextArea wrap, so that the line doesn't extend horizontally beyond the visible area?


Sharon
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I don't know of a way to do this without doing it in your program yourself after you have taken the information from the file, but before you add it to the textfield... This is going to be a pain, though...

It would be alot simpler to use a JTextArea and use the setLineWrap( true ) and setWrapStyleWord( true ) methods... if you can use Swing, of course...

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Sharada Kumaran
Greenhorn

Joined: May 23, 2001
Posts: 29
Thanks, I was looking for a method like setLineWrap(), which I already found. The problem now is when I read from a file, if the document is formatted, with fonts, and tables, a lot of junk gets displayed in the text area. Any idea how to tackle that?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Now this is a problem... If you are talking about fonts and tables in something like MS Word... they have a proprietory way of embedding this in the document, and it will look like garbage to you ( this is because they are not saving the document as text, they are saving it as binary ). If you are talking about fonts and tables in HTML, this is not as much of a problem, just use a JEditorPane instead of a JTextArea, since JEditorPane understands basic HTML...

-Nate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TextArea wrap