-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathStudentsController.java
50 lines (37 loc) · 1.41 KB
/
StudentsController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package home.controllers;
import home.model.StudentsModel;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import java.net.URL;
import java.util.ResourceBundle;
public class StudentsController implements Initializable {
@FXML
private TableView<StudentsModel> tbData;
@FXML
public TableColumn<StudentsModel, Integer> studentId;
@FXML
public TableColumn<StudentsModel, String> firstName;
@FXML
public TableColumn<StudentsModel, String> lastName;
public StudentsController()
{
}
@Override
public void initialize(URL location, ResourceBundle resources) {
studentId.setCellValueFactory(new PropertyValueFactory<>("StudentId"));
firstName.setCellValueFactory(new PropertyValueFactory<>("FirstName"));
lastName.setCellValueFactory(new PropertyValueFactory<>("LastName"));
tbData.setItems(studentsModels);
}
private ObservableList<StudentsModel> studentsModels = FXCollections.observableArrayList(
new StudentsModel(1,"Amos", "Chepchieng"),
new StudentsModel(2,"Amos", "Mors"),
new StudentsModel(3,"Amos", "Chepchieng"),
new StudentsModel(4,"Amos", "Mors")
);
}