Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with KeyListener


  • From: majidmehul@xxxxxxxxxxx (mehul mehta)
  • Subject: Problem with KeyListener
  • Date: Thu, 28 Dec 2000 18:34:13

There is a more elegant way to control
what goes into your text field. Try
extending a PlainDocument and then use
it as the model for your text field.
You can then control the text field
contents by overriding insertString.
Look at the API documentation of JTextField
for an example.
- Mehul Mehta



>From: "Ken Kelley" <kenk@xxxxxxxxxxxxxxxxx>
>To: "C.Ashok" <chandra_ashok@xxxxxxxx>, <advanced-java@xxxxxxxxxxxxxxxx>
>CC: "S Ramasamy - SYP, Chennai" <sypsys@xxxxxxxxxxxxxxx>
>Subject: RE: Problem with KeyListener
>Date: Thu, 28 Dec 2000 13:16:38 -0500
>
>Hi,
>
>What you need to do is check the key-code in the "keyPressed()" method and
>check the key-char in the "keyTyped()" method.
>
>-- Ken
>
>  -----Original Message-----
>From: C.Ashok [mailto:chandra_ashok@xxxxxxxx]
>Sent: Thursday, December 28, 2000 12:43 PM
>To: advanced-java@xxxxxxxxxxxxxxxx
>Cc: S Ramasamy - SYP, Chennai
>Subject: Problem with KeyListener
>
>
>   Hi there,
>   Iam trying register a KeyListener for my JTextField(JDK1.3).
>   I want to allow  only the numeric and character and backspace  in txt
>field.Iam able to do for numeric by using  (ke is KeyEvent)
>
>   if(Character.isDigit(ke.getKeyChar() ||
>(ke.getKeyCode()==KeyEvent.VK_BACK_SPACE))
>   {
>   -----
>   -----
>
>   }
>
>   the first part works fine but for my backspace  this doesnt work
>
>
>   Thanx in advance
>   C.Ashok
>

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx