1010import javafx .scene .control .*;
1111import javafx .scene .input .KeyCode ;
1212import javafx .scene .layout .VBox ;
13+ import javafx .scene .control .cell .PropertyValueFactory ;
1314
1415import java .util .stream .Collectors ;
1516
@@ -22,11 +23,14 @@ public class SearchController {
2223 @ FXML
2324 private Button searchButton ;
2425 @ FXML
25- private Pagination pagination ;
26- @ FXML
2726 private Label searchLabel ;
28-
27+ @ FXML
28+ private TableView tableView ;
29+ @ FXML
30+ private VBox dataContainer ;
31+
2932 private ObservableList <Person > masterData = FXCollections .observableArrayList ();
33+ private ObservableList <Person > results = FXCollections .observableList (masterData );
3034
3135 public SearchController () {
3236 masterData .add (new Person (5 , "John" , true ));
@@ -52,22 +56,21 @@ private void initialize() {
5256 searchLabel .setText (newValue );
5357 });
5458
55- pagination .setPageFactory (SearchController .this ::createPage );
56- }
59+ initTable ();
5760
58- private Node createPage (Integer pageIndex ) {
59-
60- VBox dataContainer = new VBox ();
61+ }
6162
62- TableView <Person > tableView = new TableView <>(masterData );
63+ private void initTable () {
64+ tableView = new TableView <>(FXCollections .observableList (masterData ));
6365 TableColumn id = new TableColumn ("ID" );
66+ id .setCellValueFactory (new PropertyValueFactory ("id" ));
6467 TableColumn name = new TableColumn ("NAME" );
68+ name .setCellValueFactory (new PropertyValueFactory ("name" ));
6569 TableColumn employed = new TableColumn ("EMPLOYED" );
70+ employed .setCellValueFactory (new PropertyValueFactory ("isEmployed" ));
6671
6772 tableView .getColumns ().addAll (id , name , employed );
6873 dataContainer .getChildren ().add (tableView );
69-
70- return dataContainer ;
7174 }
7275
7376 private void loadData () {
@@ -86,11 +89,10 @@ protected ObservableList<Person> call() throws Exception {
8689 };
8790
8891 task .setOnSucceeded (event -> {
89- masterData = task .getValue ();
90- pagination .setVisible (true );
91- pagination .setPageCount (masterData .size () / PAGE_ITEMS_COUNT );
92+ results = task .getValue ();
93+ tableView .setItems (FXCollections .observableList (results ));
9294 });
93-
95+
9496 Thread th = new Thread (task );
9597 th .setDaemon (true );
9698 th .start ();
0 commit comments