Hi, I'm doing an application on Java FX with the JFONIX library
I want to validate a JFXTesxtField so that I only accept numbers and another one to accept decimal numbers and that in the latter I can not enter more than 1 .
public void SoloNumerosEnteros(KeyEvent keyEvent) {
try{
char key = keyEvent.getCharacter().charAt(0);
if(Character.isLetter(key))
keyEvent.consume();
}catch (Exception ex){ }
}
FXML file:
<JFXTextField fx:id="TxtTel" focusColor="#3f8bad" prefHeight="25.0" prefWidth="194.0" style="-fx-text-inner-color: WHITE;" unFocusColor="#178bad" onKeyTyped="#SoloNumerosEnteros" />
This same code in a Normal application works for me but in this (I assume) as .consume();
does not belong to the library javafx.scene.input.KeyEvent;
does nothing% .consume();
. I hope you can help me solve these problems.