After almost a work day’s worth of searching, I was able to find a solution to my dilemna. While JTextArea has a getLineCount() method to return the number of lines, I wanted a way to also detect wrapped lines since I wanted to set my component a fixed height if the maximum height limit is reached.

This method by user Jörg in the Java forum did the trick.

To enable word wrapping in Visual Studio 2005, follow the instructions below.

On the Tools menu, select Options.
Open the Text Editor folder
Open the All Languages folder
Select General

Under Settings – select the Word wrap option

If you enable visual glyphs for word wraps, little arrows appear on the end of the line, signifying that the next text is word wrapped to the next line.

Related Posts Plugin for WordPress, Blogger...