我确实从用户那里获得了价格,但我想过滤数字并输入,每 3 位数字如 123,123,123。
txtPrice.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.matches("\\d*")){
txtPrice.setText(newValue.replaceAll("[^\\d]",""));
}
});
Run Code Online (Sandbox Code Playgroud)