🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #7944

Re: Cursor position in a JTextArea

#7944
From: John McGrath TeamB
Date: Thu, 30 Nov 2000 00:00
21 lines
1159 bytes
On 29 Nov 2000 23:35:00 GMT, Joi Ellis [TeamB] wrote:

> > does anybody know, how to get the current cursor
> > position within a JTextArea or JTextField?
> 
> I think you want to look at the underlying document object.

I don't think the Document maintains a position.

The "cursor" is called a "caret" in the Swing text package.  You can 
get the caret position for any JTextComponent (including JTextArea and 
JTextField) with the getCaretPosition() method.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <MPG.148feabe8c640694989d7a@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3A258C30.8070909@franke.com> <9043r4$4qu9@bornews.inprise.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,cb649420cdff04f3
X-Google-Attributes: gid111d45,public
From: John McGrath  [TeamB] <ng-b@JPMcGrath.net>
Subject: Re: Cursor position in a JTextArea
Date: 2000/11/30
Message-ID: <MPG.148feabe8c640694989d7a@forums.borland.com>
X-Deja-AN: 699487803
References: <3A258C30.8070909@franke.com> <9043r4$4qu9@bornews.inprise.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing