JTextArea two lines limit
I have a String of certain length and a JTextArea of specific width.
What I need is a way to trim the string so it would fit to exactly two
rows of JTextArea.
Kinda like this:
String:
"This is a string that surely would not fit the JTextArea"
JTextArea:
This is a string that
surely would not fit t...
It wraps at the word on the first line, but cuts at the second so max
number of characters would fit followed by three dots.
I could get a DocumentListener and remove a char by char when line number
limit is exceded, and adding dots/removing additional characters when line
number criteria is met...
But this would be used a lot of times in a lot of places, so I'm looking
for a maybe faster solution, if there is one...
Font is unfortunately not monospaced.
No comments:
Post a Comment