I have small Java GUI program (screenshot below). One of the values is "Passport Number".
This field should contain 11 symbols. Once the user has entered a value in this field, I want to check the correct number of symbols are in place and set string "error" in Label item "Label1" if not.
I tried this:
private void btnSendActionPerformed(java.awt.event.ActionEvent evt) {
String error;
if(passportn.length()!=11) {
error="error";
label1.setText(error);
}
}
This works but only when a button is pressed. Instead I want this to happen as the user enters passport number.