【发布时间】:2018-07-18 15:08:32
【问题描述】:
我确实从用户那里得到了价格,但我想过滤数字并放置,每 3 位数字,如 123,123,123。
txtPrice.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.matches("\\d*")){
txtPrice.setText(newValue.replaceAll("[^\\d]",""));
}
});
【问题讨论】:
-
看看 TextFormatter - 使用它您可以微调文本输入的格式、验证和导航