File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Probelm with KeyListener" Watch "Probelm with KeyListener" New topic

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.
I agree. Here's the link:
subject: Probelm with KeyListener
Similar Threads
automatically update score when user input in JTextField..
Apply 2d array of answer to the right position of JTextField grid with JCheckBox
keyboard events
JTextField getText() no Enter pressed
want to do some action when input is typed in Swing JPanel components