How can you tell, in a KeyListener, what the length of the document is? I'm
struggling with wanting to only do something on the first key pressed on a
document, and after that, to ignore the KeyPress altogether, but cannot
figure out the length of the underlying document.
Anyone encounter this before? -Ike
Rhino - 02 Apr 2006 19:36 GMT
> How can you tell, in a KeyListener, what the length of the document is?
> I'm
[quoted text clipped - 3 lines]
>
> Anyone encounter this before? -Ike
Why do you care about the document length? If you are only intended to
capture or react to the first key pressed, that has nothing to do with the
document length as far as I can see. You should only need to monitor your
KeyListener increment a counter for each key pressed; then ignore everything
but the first key press (or disable the listener altogether after the first
key press.) Right?
--
Rhino
Martin Gregorie - 02 Apr 2006 19:46 GMT
> How can you tell, in a KeyListener, what the length of the document is? I'm
> struggling with wanting to only do something on the first key pressed on a
> document, and after that, to ignore the KeyPress altogether, but cannot
> figure out the length of the underlying document.
Why would you *care* how long the document is? The problem as you
describe it, is independent of document size. All you want to know is
whether its the first key pressed or not.
Sounds like a "first keystroke" boolean in your KeyListener is the
correct solution.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Chris Smith - 02 Apr 2006 20:02 GMT
> How can you tell, in a KeyListener, what the length of the document is? I'm
> struggling with wanting to only do something on the first key pressed on a
> document, and after that, to ignore the KeyPress altogether, but cannot
> figure out the length of the underlying document.
>
> Anyone encounter this before? -Ike
I suppose you'd give the KeyListener access to the Document, perhaps by
passing it as a parameter to the constructor.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation