I am coding a textEditor with the awt (not with swing) and i want to insert a text on actual Cursorposition. With int nu=editor.getCaretPosition(); i will get the actual Linenumber - but HOW DO I APPEND THE TEXT ON THIS POSITION???
Originally posted by da funky chicken: With ... getCaretPosition() ... i will get the actual Linenumber
That's not correct. With getCaretPosition() you get the caret position within the TextArea (or whatever TextComponent) with regards to the beginning of the String that the TextArea contains. That String begins at the top left corner. The top left corner has a position of 0. If "Hello," were at the beginning of the TextArea, and the caret were between the two 'l' characters, then getCaretPosition() would return 3 - not the line number. Good Luck.
Joined: May 10, 2001
da funky chicken Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however, your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy. Thanks again and we hope to see you around the ranch!!
Joined: Nov 22, 2008
Thanx for help, dirk. It worx!!! [ March 28, 2002: Message edited by: da funky chicken ]