Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

KeyListener First Key Typed

Thread view: 
Ike - 02 Apr 2006 17:25 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
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.