public class SampleController {
@FXML TextField txtNome;
@FXML TextField txtNumero;
@FXML TextField txtDistancia;
@FXML DatePicker dataNasc;
@FXML TableView<Pessoa> tblPessoa;
@FXML TableColumn<Pessoa, String> colNome;
@FXML TableColumn<Pessoa, Number> colNumero;
@FXML TableColumn<Pessoa, String> colFaixa;
@FXML TableColumn<Pessoa, Number> colDistancia;
private ArrayList<Pessoa> pessoas = new ArrayList<Pessoa>();
public void initialize() {
inicializaTabelaTbl();
}
private void inicializaTabelaTbl() {
colNome.setCellValueFactory(cellData -> cellData.getValue().nomeProperty());
colNumero.setCellValueFactory(cellData -> cellData.getValue().numeroProperty());
colDistancia.setCellValueFactory(cellData -> cellData.getValue().distanciaProperty());
colFaixa.setCellValueFactory(cellData -> cellData.getValue().faixaProperty()); //**<- aqui ocorre o null pointer exception**
}
}
Na classe Pessoa…
public class Pessoa {
private StringProperty nome = new SimpleStringProperty();
private IntegerProperty numero = new SimpleIntegerProperty();
private IntegerProperty idade = new SimpleIntegerProperty();
private IntegerProperty distancia = new SimpleIntegerProperty();
private StringProperty nasc = new SimpleStringProperty("");
private StringProperty faixa = new SimpleStringProperty("");
public final StringProperty nomeProperty() {
return this.nome;
}
public final String getNome() {
return this.nomeProperty().get();
}
public final void setNome(final String nome) {
this.nomeProperty().set(nome);
}
public final StringProperty faixaProperty() {
return this.faixa;
}
public final String getFaixa() {
return this.faixaProperty().get();
}
public final void setFaixa(final String faixa) {
this.faixaProperty().set(faixa);
}
e os outros getters and setters.
Não sei se ficou claro, agradeço desde já