Jump to content
  • Advertisement
Sign in to follow this  
ManaStone

[java] Getting lines in JTextArea

This topic is 2766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there anyway I can figure out the number of lines of text on a JTextArea if the lines there are because I set the line wrap property to true? The getLineCount() function only seems to get the number of lines that are due to a "\n" character.

Am I going to have to figure that out myself or is there some kind of function that can help me?

Share this post


Link to post
Share on other sites
Advertisement
This is the most useful example I have found.

It requires the use of "javax.swing.text.Utilities", which I didn't know existed until now :)

You just need to modify the example a bit. Instead of building a new String, you'll want to increment and return a counter every time you find a "soft" new line.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!