小编Dev*_*r66的帖子

如何在JavaFX中的TextField中强制双输入?

如何确保用户只在给定的TextField中输入双值

我找到了一个整数解决方案,我无法将其用于双打.我应该怎么写,而不是"\\d*""[^\\d]"使其双打工作?

textField.textProperty().addListener(new ChangeListener<String>() {
    @Override
    public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
        if (!newValue.matches("\\d*")) {
            textField.setText(newValue.replaceAll("[^\\d]", ""));
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

java javafx input textfield

3
推荐指数
1
解决办法
7824
查看次数

哪些变量在JavaFX/Hibernate应用程序中使用

假设我们Entity/Class想要在JavaFX组件中的TableView中填充一个Person.

我应该在什么类型的数据中填充Person类 - String或者SimpleStringProperty

在这两种情况下,我都没有完全得到我想要的东西.如果我将使用String变量,我将无法收听在TableView中完成的任何更改(根据postClickMe).另一方面,如果我将使用SimpleStringProperty我将得到和异常,hibernate无法转换SimpleStringProperty为String,这是在数据库中使用的类型.怎么能更巧妙地完成呢?

@Entity
public Person {
    private String name;     // or SimpleStringProperty
    private String Surname; // or SimpleStringProperty

    // getter and setters removed to simplify example
}
Run Code Online (Sandbox Code Playgroud)

java hibernate javafx

3
推荐指数
1
解决办法
444
查看次数

标签 统计

java ×2

javafx ×2

hibernate ×1

input ×1

textfield ×1