I would like to keep on checking a JTextField until the field equals ten digits. When the JTextField equals ten digits then an event will happen. I want to do this without a button.
Here is what i tried to do:
JTextField get = new JTextField(10);
String a;
public className(String title)
{
//Some other code here
add(get);
}
//The class implements the Runnable class
public void run()
{
for(;;)
{
a = get.getText();
if(a.length() == 10)
{
System.out.println("You entered 10 digits");
break;
}
}
}
But my way does not work. How do I fix this?