Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextArea Problem

 
Florin Florentin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I would like to ask you how can i arrange the text wich i copy into a jTextArea? Now it appears only on 1 long line.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you read the JTextArea API Documentation (i.e. it's JavaDocs) you will see this comment in the class description:


The java.awt.TextArea has the ability to do line wrapping. This was controlled by the horizontal scrolling policy. Since scrolling is not done by JTextArea directly, backward compatibility must be provided another way. JTextArea has a bound property for line wrapping that controls whether or not it will wrap lines. By default, the line wrapping property is set to false (not wrapped).


Take a look through that Javadoc page I linked to. You will see there is a method to set Line Wrap to true. I won't tell you the name of it, but it is there. Generally when you want to set a property on something 99% of the time the name of the method is setPropertyName. And you want to set the Line Wrap property.

 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
p.s. The reason I'm not exactly telling you the name is not to be mean or anything. Rather to help you learn how to read the Javadoc for a class. It's an essential skill to learn. If you have problems finding it, let us know and we can help further.
 
Florin Florentin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mark .
I found the setLineWrap property. I'll try next time to search more before posting a question.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice work.
 
Florin Florentin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're ironic
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Florin Florentin wrote:Thank you Mark .
I found the setLineWrap property. I'll try next time to search more before posting a question.

There's probably one more related method that you'll want to explore here: setWrapStyleWord(boolean word)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic