> Hello,
>
[quoted text clipped - 3 lines]
> serial communication terminal: send each line of text over the serial
> port after CR.
Look up getLineOfOffset and getLineEnd/StartOffset in the documentation.

Signature
Daniel Sjöblom
> Hello,
>
[quoted text clipped - 7 lines]
>
> Aaron Boxer
I haven't compiled this, but this should be pretty close to what you want.
Document document = textArea.getDocument();
Element rootElem = document.getDefaultRootElement();
int numLines = rootElem.getElementCount();
Element lineElem = rootElem.getElement(numLines - 1);
int lineStart = lineElem.getStartOffset();
int lineEnd = lineElem.getEndOffset();
String lineText = document.getText(lineStart, lineEnd - lineStart);

Signature
Bill Tschumy
Otherwise -- Austin, TX
http://www.otherwise.com
Aaron Boxer - 30 Sep 2003 14:34 GMT
Hi Bill,
thanks for your reply!
I just had to change one line, because of zero offsets:
Element lineElem = rootElem.getElement(numLines - 2);
Cheers,
Aaron
> > Hello,
> >
[quoted text clipped - 17 lines]
> int lineEnd = lineElem.getEndOffset();
> String lineText = document.getText(lineStart, lineEnd - lineStart);