I would like that while I write characters it should be checked if the new String complies with what in the regular expression is defined.
I can say that the Strign is entering it in a TextField
this is the regular expression - > "[0-9] {8} [A-Z]"
this the code of the event:
public RestrictiveField(){
textProperty().addListener(new ChangeListener<String>(){
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
//patron.get() es el metodo que carga el patron
Pattern p= Pattern.compile(patron.get());
Matcher m= p.matcher(newValue);
if(!m.lookingAt()){
setStyle("-fx-control-inner-background: red; -fx-font-size: 16;");
}
if(newValue.equals("")|| m.lookingAt()){
setStyle("fx-control-inner-background: transparent;");
}
}
});
}
The output of this, is just the opposite of what I'm looking for with the code I have so far
to see if someone can help me.