Ant*_* J. 6 tableview javafx-2
我一直在寻找有关将数据刷新到tableview的信息.我试图直接修改模型,但我得到了一个bug.我修改了模型,但表格没有刷新,只有当我移动一列时,表格才显示修改后的值.
为了向您展示一个示例(13-6),我将学习该教程:
http://docs.oracle.com/javafx/2/ui_controls/table-view.htm#CJABIEED
我修改它包括一个按钮,并在其动作中:
Button button = new Button("Modify");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
String name = table.getItems().get(0).getFirstName();
name = name + "aaaa";
table.getItems().get(0).setFirstName(name);
}
});
final VBox vbox = new VBox();
vbox.setSpacing(5);
vbox.getChildren().addAll(label, table, button);
vbox.setPadding(new Insets(10, 0, 0, 10));
Run Code Online (Sandbox Code Playgroud)
我想这是tableview中的一个错误,但有没有机会解决这个问题?
谢谢!
Ser*_*nev 21
使TableView能够跟踪将相关字段公开为JavaFX属性所需的数据更改.Person从教程中向类添加下一个方法:
public SimpleStringProperty firstNameProperty() {
return firstName;
}
public SimpleStringProperty lastNameProperty() {
return lastName;
}
public SimpleStringProperty emailProperty() {
return email;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24019 次 |
| 最近记录: |