• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

TextArea wrap

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic