This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Probelm with KeyListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Probelm with KeyListener" Watch "Probelm with KeyListener" New topic
Author

Probelm with KeyListener

seema prakash
Ranch Hand

Joined: Nov 17, 2004
Posts: 59
I have a JTextField and a JCheckBox. I want the JCheckBox
to be enabled only when the JTextField is not empty.
I have implemented the KeyListener for the JTextField.
But, only when the second character is entered in the JTextField
the Listener seems work. Please help.

seema prakash
Ranch Hand

Joined: Nov 17, 2004
Posts: 59
I got it working ! I should have written the code in the KeyReleased method instead of the KeyTyped.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Probelm with KeyListener
 
Similar Threads
want to do some action when input is typed in Swing JPanel components
keyboard events
automatically update score when user input in JTextField..
JTextField getText() no Enter pressed
Apply 2d array of answer to the right position of JTextField grid with JCheckBox