Can someone help me please. I am using a Scanner Class and want to count characters entered in the textfield. Unfortunately, backspace and any key (Ctr,Alt,Capslock) for that matter is counted as a character and that increments the counter by 1.
Here is the code
String ab="^[A-Za-z0-9]+$";
public void keyReleased(KeyEvent ke) throws NoSuchElementException{
Scanner scann=new Scanner(Jtextfield.getText());
{
String sarwa=scann.next(ab);
if(true)
i++;
champo.setText(" "+Integer.toString(i));
}
Thankyou,
ARZ