Problema JavaFX

2 respostas
java
G

Estou com este erro

atent -f C:\Users\55419\Documents\NetBeansProjects\BeTheHero -Djavac.includes=bethehero/ListaCasos.java -Dnb.internal.action.name=run.single -Drun.class=bethehero.ListaCasos run-single

init:

Deleting: C:\Users\55419\Documents\NetBeansProjects\BeTheHero\build\built-jar.properties

deps-jar:

Updating property file: C:\Users\55419\Documents\NetBeansProjects\BeTheHero\build\built-jar.properties

Compiling 1 source file to C:\Users\55419\Documents\NetBeansProjects\BeTheHero\build\classes

compile-single:

run-single:

Exception in Application start method

java.lang.reflect.InvocationTargetException

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 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)

at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)

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.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)

Caused by: java.lang.RuntimeException: Exception in Application start method

at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)

at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)

at java.lang.Thread.run(Thread.java:748)

Caused by: javafx.fxml.LoadException:

file:/C:/Users/55419/Documents/NetBeansProjects/BeTheHero/dist/BeTheHero.jar!/View/ListaCasos.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at bethehero.ListaCasos.start(ListaCasos.java:34)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Caused by: java.lang.NullPointerException

at Controllers.ListaCasosController.initTable(ListaCasosController.java:117)

at Controllers.ListaCasosController.initialize(ListaCasosController.java:110)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)

 12 more

Exception running application bethehero.ListaCasos

C:\Users\55419\Documents\NetBeansProjects\BeTheHero\nbproject\build-impl.xml:1052: The following error occurred while executing this line:

C:\Users\55419\Documents\NetBeansProjects\BeTheHero\nbproject\build-impl.xml:806: Java returned: 1

FALHA NA CONSTRUÇÃO (tempo total: 1 segundo)

Este é o meu controller

package Controllers;

import DAO.IncidentsDAO;

import Model.Incidents;

import bethehero.BeTheHero;

import bethehero.CadastrarCasos;

import bethehero.ListaCasos;

import bethehero.LoginOng;

import java.io.IOException;

import java.net.URL;

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.Button;

import javafx.scene.control.TableColumn;

import javafx.scene.control.TableView;

import javafx.scene.control.TextField;

import javafx.scene.control.cell.PropertyValueFactory;

import javafx.scene.input.KeyCode;

import javafx.scene.input.KeyEvent;

import javafx.scene.input.MouseEvent;

import javafx.stage.Stage;
public class ListaCasosController implements Initializable {

@FXML

private Button btFechar;
@FXML
private Button btVoltar;

@FXML
private TableView<Incidents> tabela;

@FXML
private Button btCadastar;

@FXML
private Button btAtualizar;

@FXML
private Button btPesquisar;

@FXML
private Button btDeletar;

@FXML
private TextField txPesquise;

@FXML
private Button btAlterar;

@FXML
private TableColumn<Incidents, String> clmCaso;

@FXML
private TableColumn<Incidents, String> clmDescricao;

@FXML
private TableColumn<Incidents, Float> clmValor;
/**
 * Initializes the controller class.
 * @param url
 */

public void initialize(URL url, ResourceBundle rb) {
    btFechar.setOnMouseClicked((MouseEvent e) ->{
        fecha();
    });
    
    btFechar.setOnKeyPressed((KeyEvent e)->{
        if(e.getCode() == KeyCode.ENTER){
           fecha();
        }
    });
    
    btVoltar.setOnMouseClicked((MouseEvent e) ->{
        VoltaInicio();
    });
    
    btVoltar.setOnKeyPressed((KeyEvent e)->{
        if(e.getCode() == KeyCode.ENTER){
           VoltaInicio();
        }
    });
    
    btCadastar.setOnMouseClicked((MouseEvent e) ->{
        Ir();
    });
    
    btCadastar.setOnKeyPressed((KeyEvent e)->{
        if(e.getCode() == KeyCode.ENTER){
           Ir();
        }
    });
    
      initTable();
}    

/**
 *
 */
public void initTable(){
    clmCaso.setCellValueFactory(new PropertyValueFactory("title"));
    clmDescricao.setCellValueFactory(new PropertyValueFactory("description"));
    clmValor.setCellValueFactory(new PropertyValueFactory("value"));
    tabela.setItems(atualizaTabela());
}

public ObservableList<Incidents> atualizaTabela(){
    IncidentsDAO dao = new IncidentsDAO();
    return FXCollections.observableArrayList(dao.getList());
}

  public void fecha(){
    ListaCasos.getStage().close();
}

public void VoltaInicio(){
    BeTheHero inic = new BeTheHero ();
    fecha();
    try {
      inic.start(new Stage());
    } catch (IOException ex) {
      Logger.getLogger(InicalController.class.getName()).log(Level.SEVERE, null, ex);
        }
}

public void Ir(){
    CadastrarCasos cc = new CadastrarCasos ();
    fecha();
    try {
      cc.start(new Stage());
    } catch (IOException ex) {
      Logger.getLogger(InicalController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

}

2 Respostas

rodriguesabner

Verifica se tá tudo certo nessa linha aí, tá dando nullpointer, e vê se tem algo nessa lista tbm, se não tiver, o erro está acontecendo por isso

GladsonReis

Olha a causa.
Esta lista sua ai esta vazia/nula
Verifique ela

Aguardo retorno

Criado 7 de abril de 2020
Ultima resposta 8 de abr. de 2020
Respostas 2
Participantes 3