Zdravím , mám problém s TableView , mám 3 stlpce a potrebujem ich inicializovat cez setCellValueFactory()
no vyhadzuje mi to NullpointerExeption a netušim prečo.
@FXML
private TableView<Hosts> table;
@FXML
private TableColumn<Hosts,String> hostsColumn,subnetsColumn,growthColumn;
private ObservableList<Hosts> tableData = FXCollections.observableArrayList();
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("host.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 500, 550));
primaryStage.setMinHeight(550);
primaryStage.setMinWidth(500);
primaryStage.show();
hostsColumn.setCellValueFactory(new PropertyValueFactory<Hosts, String>("h"));
subnetsColumn.setCellValueFactory(new PropertyValueFactory<Hosts, String>("S"));
growthColumn.setCellValueFactory(new PropertyValueFactory<Hosts, String>("G"));
table.setItems(tableData);
}
public class Hosts
{
private String h;
private String s;
private String g;
public Hosts(String h, String s, String g) {
this.h = h;
this.s = s;
this.g = g;
}
public String getH() {
return h;
}
public void setH(String h) {
this.h = h;
}
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
public String getG() {
return g;
}
public void setG(String g) {
this.g = g;
}
}
Chyba je pri hostsColumn.setCellValueFactory(), vďaka za pomoc