How can I restrict the input from the user to only hexadecimal values? With decimal notation the range is from 0 to 16383, but I would like to let the user type an hexadecimal n
best way to do it is with regular expressions:
yourTextField.textProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue extends String> observable, String oldValue,
String newValue) {
if (!newValue.matches("^[0-9A-F]+$")) {
yourTextField.setText(newValue.replaceAll("[^\\d]", ""));
}
}
});
Is this what your are looking for?