Basically all I want to do is limit a JTextArea to, say, four lines max. I mean 4 physical lines, not 4 sentences. Now I know about PlainDocument and I know how to determine how many carriage returns there are in the JTextArea. But sometimes there will be carriage returns and sometimes there will just be linewraps at a word space. Both create "new lines" in my situation.
So I'm struggling determining how many lines are in the JTextArea when carriage returns aren't used and how to limit the max number of lines. I have got as far as stopping entry when the fourth line is at its maximum width but this also stops entry on previous lines if the user moves the cursor back up a line.
At this point I'm going around in circles and need a fresh approach. Any code examples or thoughts would be sincerely appreciated.