• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TextArea wrap

 
Sharada Kumaran
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sharada Kumaran
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic