javafx fill fxml tableview with data

Solutions on MaxInterview for javafx fill fxml tableview with data by the best coders in the world

showing results for - "javafx fill fxml tableview with data"
Alessandro
29 Oct 2017
1public class MyController implements Initializable {
2
3    @FXML private TableView<User> tableView;
4    @FXML private TableColumn<User, String> UserId;
5    @FXML private TableColumn<User, String> UserName;
6    @FXML private TableColumn<User, String> Active;
7
8    @Override
9    public void initialize(URL location, ResourceBundle resources) {
10        UserId.setCellValueFactory(new PropertyValueFactory<User, String>("id"));
11        UserName.setCellValueFactory(new PropertyValueFactory<User, String>("name"));
12        Active.setCellValueFactory(new PropertyValueFactory<User, String>("active"));
13
14        tableView.getItems().setAll(parseUserList());
15    }
16    private List<User> parseUserList(){
17        // parse and construct User datamodel list by looping your ResultSet rs
18        // and return the list   
19    }
20}