Automatically update rows in tableview from the model
•
Java
I've been looking for information about refreshing data to tableview I tried to modify the model directly, but I got a bug I modified the model, but the table did not refresh. The table displays the modified value only when I move a column
To show you an example (13-6), I will take this tutorial:
http://docs.oracle.com/javafx/2/ui_controls/table-view.htm#CJABIEED
I modified it to include a button and in its action:
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 V@R_446_2419@ v@R_446_2419@ = new V@R_446_2419@(); v@R_446_2419@.setSpacing(5); v@R_446_2419@.getChildren().addAll(label,table,button); v@R_446_2419@.setPadding(new Insets(10,10));
I think this is an error in tableview, but is there a chance to solve this problem?
thank you!
Solution
Enables tableview to track data changes required to expose related fields as JavaFX properties From the tutorial, add the next method to the person class:
public SimpleStringProperty firstNameproperty() { return firstName; } public SimpleStringProperty lastNameproperty() { return lastName; } public SimpleStringProperty emailproperty() { return email; }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码