first of this question in not exactly like what it is marked duplicate of. i'm trying to add data to a single column tableview but i can't figure for my life what am i missing. i only see an empty column. i have checked the naming convention, which you can see is ok. if need anything else please ask. thanks
//Empolyee class
public class Employee {
String name;
Employee(String name){
this.name = name;
}
}
// Layout
private TableView<Employee> dataBase() {
TableView<Employee> table = new TableView<>();
TableColumn<Employee, String> name = new TableColumn<>("Name");
name.setMinWidth(120);
name.setCellValueFactory(new PropertyValueFactory<>("name"));
table.setItems(getEmployees());
table.getColumns().add(name);
return table;
}
private ObservableList<Employee> getEmployees() {
ObservableList<Employee> data =FXCollections.observableArrayList();
data.add(new Employee("DOE-1"));
data.add(new Employee("DOE-2"));
data.add(new Employee("DOE-3"));
data.add(new Employee("DOE-4"));
return data;
}
HBox body() {
HBox body = new HBox();
body.getChildren().addAll(dataBase());
return body;
}
public void start(Stage primaryStage) {
mainPane.getChildren().addAll(body());
primaryStage.setResizable(false);
primaryStage.setScene(scene);
primaryStage.show();
}