I'm getting an error when I try to throw information from an array into a table. It's NullPointerException when I try to set the columns.
The array is being mounted with all positions. One of the columns in the table is a checkBox. I already did that and it worked but the table was in my main FXML, so I changed the table to another FXML, which opens at startup and stops working.
The class where I mount my arrayList has enterprise system information, so it's kind of tricky to put integer here, but it's being done correctly.
package views;
import java.beans.PropertyVetoException;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.CheckBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import model.dao.CapturaSISBB;
import model.dao.ConsultasSQL;
import model.domain.op_inicial;
public class FXML_TabelasController implements Initializable {
@FXML
private AnchorPane FXMLTabelas;
@FXML
private TableColumn<op_inicial, String> coluna_Operacao1;
@FXML
private TableColumn<op_inicial, Double> coluna_valorParcela1;
@FXML
private TableColumn<op_inicial, Double> coluna_Valor1;
@FXML
private TableColumn<op_inicial, String> coluna_situacao1;
@FXML
private TableColumn<op_inicial, Boolean> coluna_check_selecao1;
@FXML
private TableView<op_inicial> tableOperacoes;
private String mci;
private JanelaSisbb sisbb;
private ObservableList<op_inicial> observableListOperacao;
private List<op_inicial> listop;
CapturaSISTEMA captura_SISTEMA = new CapturaSISTEMA();
@Override
public void initialize(URL url, ResourceBundle rb) {
}
@FXML
public void preencheTabelas(TextField txtChave, String mci) throws PropertyVetoException, Throwable {
try {
listop = captura_SISTEMA.operacoes(txtChave, mci);
coluna_check_selecao1.setCellValueFactory(new PropertyValueFactory<>("selecao")); // quando chega aqui ele já pula para o erro e nao consegue setar.
coluna_Operacao1.setCellValueFactory(new PropertyValueFactory<>("operacao"));
coluna_valorParcela1.setCellValueFactory(new PropertyValueFactory<>("valorDaParcela"));
coluna_Valor1.setCellValueFactory(new PropertyValueFactory<>("valor"));
coluna_situacao1.setCellValueFactory(new PropertyValueFactory<>("situacao"));
coluna_check_selecao1.setCellFactory(CheckBoxTableCell.forTableColumn(coluna_check_selecao1));
observableListOperacao = FXCollections.observableArrayList(listop);
tableOperacoes.setItems(observableListOperacao);
} catch (Throwable ex) {
Logger.getLogger(FXML_TabelasController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Here is my class with getters and setters
package model.domain;
import java.util.ArrayList;
import java.util.List;
import javafx.beans.property.SimpleBooleanProperty;
/**
*
*/
public class op_inicial {
private SimpleBooleanProperty selecao;
private String operacao;
private Double valor;
private String situacao;
private Double valorDaParcela;
public op_inicial(SimpleBooleanProperty selecao, String operacao, Double valor, String situacao, Double valorDaParcela) {
this.selecao = selecao;
this.operacao = operacao;
this.valor = valor;
this.situacao = situacao;
this.valorDaParcela = valorDaParcela;
}
public op_inicial() {
}
public Double getValorDaParcela() {
return valorDaParcela;
}
public void setValorDaParcela(Double valorDaParcela) {
this.valorDaParcela = valorDaParcela;
}
public op_inicial(Double valorDaParcela) {
this.valorDaParcela = valorDaParcela;
}
public Double valorDaParcela (){
return valorDaParcela;
}
public boolean isSelected() {
return selecao.get();
}
public SimpleBooleanProperty selecaoProperty() {
return selecao;
}
public void setSelecao(boolean selecao) {
this.selecao = this.selecao;
}
public String getOperacao() {
return operacao;
}
public String operacao() {
return operacao;
}
public void setOperacao(String operacao) {
this.operacao = operacao;
}
public Double getValor() {
return valor;
}
public Double valor() {
return valor;
}
public void setValor(Double valor) {
this.valor = valor;
}
public String getSituacao() {
return situacao;
}
public String situacao() {
return situacao;
}
public void setSituacao(String situacao) {
this.situacao = situacao;
}
}
My array is bringing all the positions correctly, in the Scene Builder the controller is also correct. Follow the error below.
GRAVE: null
java.lang.NullPointerException
at views.FXML_TabelasController.preencheTabelas(FXML_TabelasController.java:70)
at views.FXMLTelaPrincipalController.portal(FXMLTelaPrincipalController.java:210)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8413)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:380)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:294)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:416)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:415)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)