Java - Problema con Java FX

   
Vista:

Problema con Java FX

Publicado por Alexis (1 intervención) el 03/11/2017 03:58:29
Hola buenas, he estado haciendo pruebas con NeatBeans y Java FX para probar su interfaz pero me da un error que ni siguiendo las pautas de un PDF desaparece, ya no se si es por culpa de mi NeatBeans o no, no lo se.

intuyo que el erro esta aqui:
1
2
Caused by: java.lang.NullPointerException
 at flightsfx.FXMLMainViewController.initialize(FXMLMainViewController.java:81)

pero no veo nada en esa fila, lo veo todo bien

Os dejo el codigo espero que me podais ayudar. Muchas gracias y un saludo!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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$155(LauncherImpl.java:182)
 at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/killtrols/Documents/NetBeansProjects/FlightsFX%20-%20copia/dist/FlightsFX.jar!/flightsfx/FXMLMainView.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.loadImpl(FXMLLoader.java:3214)
 at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
 at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
 at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
 at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
 at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
 at flightsfx.FlightsFX.start(FlightsFX.java:22)
 at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
 at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
 at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
 at java.security.AccessController.doPrivileged(Native Method)
 at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
 ... 1 more
Caused by: java.lang.NullPointerException
 at flightsfx.FXMLMainViewController.initialize(FXMLMainViewController.java:81)
 at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
 ... 17 more
Exception running application flightsfx.FlightsFX
C:\Users\killtrols\Documents\NetBeansProjects\FlightsFX - copia\nbproject\build-impl.xml:1052: The following error occurred while executing this line:
C:\Users\killtrols\Documents\NetBeansProjects\FlightsFX - copia\nbproject\build-impl.xml:806: Java returned: 1
BUILD FAILED (total time: 2 seconds)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package flightsfx;
 
import flightsfx.model.Flight;
import flightsfx.utils.FileUtils;
import flightsfx.utils.MessageUtils;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.OptionalDouble;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
 
/**
 *
 * @author killtrols
 */
public class FXMLMainViewController implements Initializable {
 
    @FXML
    private TableView<Flight> TV;
    @FXML
    private TableColumn<Flight,String> TVFlightNumber;
    @FXML
    private TableColumn<Flight,String> TVDestination;
    @FXML
    private TableColumn<Flight,LocalDateTime> TVDeparture;
     @FXML
    private TableColumn<Flight,LocalTime> TVDuration;
 
     @FXML
     private TextField TextFlightNumber;
     @FXML
     private TextField TextDestination;
     @FXML
     private TextField TextDeparture;
     @FXML
     private TextField TextDuration;
 
 
     @FXML
     private ChoiceBox<String> filterChoice;
 
     @FXML
     private Button ButtonDelete;
     @FXML
     private Button ButtonAdd;
 
 
    private List<Flight> flights;
    private ObservableList<Flight> currentFlight;
 
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        DateTimeFormatter dtfDate = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
        DateTimeFormatter dtfHour = DateTimeFormatter.ofPattern("H:mm");
 
        try {
            TV.setPlaceholder(new Label("No items to show..."));
            TVFlightNumber.setCellFactory(new PropertyValueFactory("flightNumber"));
            TVDestination.setCellFactory(new PropertyValueFactory("destination"));
            TVDeparture.setCellFactory(new PropertyValueFactory("time"));
            TVDuration.setCellFactory(new PropertyValueFactory("duration"));
 
            flights = FileUtils.loadFlights();
 
            ObservableList<Flight> data = FXCollections.observableArrayList(new Flight("054ASp","ASPE",LocalDateTime.parse("30/10/2017 01:06",dtfDate),LocalTime.parse("0:30",dtfHour)));
            TV.setItems(data);
        } catch (IOException ex) {
            Logger.getLogger(FXMLMainViewController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Revisar política de publicidad