I am trying to create a table view with check box. For some reason, the method "initialize" doesn't run. When I run my code, the table appears without the fields inside. the print message "TEST" isn't printed. Could someone help me figure this out?
public class Main extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("AddTransactionsToBlock.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
public class AddTransactionsToBlockController implements Initializable {
@FXML
private TableColumn<TableSetterGetter, String> name;
@FXML
private TableColumn<TableSetterGetter, Integer> id;
@FXML
private TableColumn<TableSetterGetter, CheckBox> select;
@FXML
private TableView<TableSetterGetter> tableView;
ObservableList <TableSetterGetter> list = FXCollections.observableArrayList();
@Override
public void initialize(URL url, ResourceBundle rb) {
System.out.println("TEST PRINT");
for (int i=0; i<10; i++) {
CheckBox ch = new CheckBox("" + i);
list.add(new TableSetterGetter(i, "HELLO", ch));
}
tableView.setItems(list);
id.setCellValueFactory(new PropertyValueFactory<TableSetterGetter,Integer>("id"));
name.setCellValueFactory(new PropertyValueFactory<TableSetterGetter,String>("name"));
select.setCellValueFactory(new PropertyValueFactory<TableSetterGetter,CheckBox>("checkBox"));
}
}
Aucun commentaire:
Enregistrer un commentaire