2013-10-28 29 views
3

我有一個JavaFX應用程序,我的工作電腦上偉大的,但不能在我的筆記本電腦 在所有的工作,我相信我有我的電腦和我的筆記本電腦上相同的設置:的JavaFX的NetBeans

  • 的NetBeans 7.4
  • 的Java 1.7.0_45

這是啓動方法

@Override 
public void start(Stage stage) throws Exception { 
    FXMLLoader loader = new FXMLLoader(); 

    Parent fxmlRoot = (Parent) loader.load(new FileInputStream(new File(
      "src\\com\\gasstation\\views\\main-layout.fxml"))); 

    Scene scene = new Scene(fxmlRoot); 

    stage.setScene(scene); 
    stage.show(); 

    GasStationXmlParser parser = new GasStationXmlParser("src\\config.xml"); 
    newGasStation = parser.getGasStations(); 

    MainController mainController = loader.getController(); 

    for (GasStation station : newGasStation) { 
     mainController.setConfigData(station); 
    } 

    startAllGasStations(); 
} 

,當我嘗試運行該應用程序我得到:

java.lang.NullPointerException 
at javafx.fxml.FXMLLoader.equals(FXMLLoader.java:1855) 
at javafx.fxml.FXMLLoader.isCyclic(FXMLLoader.java:1867) 
at javafx.fxml.FXMLLoader.access$2200(FXMLLoader.java:66) 
at javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:935) 
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:565) 
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2348) 
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2164) 
at com.gasstation.main.Main.start(Main.java:27) 
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319) 
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:216) 
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179) 
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176) 
at java.security.AccessController.doPrivileged(Native Method) 
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176) 
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76) 
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) 
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17) 
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67) 
at java.lang.Thread.run(Thread.java:744) 
Exception in Application start method 
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method 
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403) 
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47) 
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115) 
    at java.lang.Thread.run(Thread.java:744) 
Caused by: java.lang.NullPointerException 
    at javafx.stage.Window.impl_visibleChanging(Window.java:816) 
    at javafx.stage.Stage.impl_visibleChanging(Stage.java:922) 
    at javafx.stage.Window$9.invalidated(Window.java:690) 
    at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127) 
    at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161) 
    at javafx.stage.Window.setShowing(Window.java:779) 
    at javafx.stage.Window.show(Window.java:794) 
    at javafx.stage.Stage.show(Stage.java:229) 
    at com.gasstation.main.Main.start(Main.java:37) 
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319) 
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:216) 
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179) 
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176) 
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76) 
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) 
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17) 
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67) 
    ... 1 more 
Java Result: 1 

我解決不了什麼東西沒有?

任何想法?

+2

之前調用loader.setLocation(Main.class.getResource(/com/gasstation/views/main-layout.fxml));顯示,美國'com.gasstation.main.Main.start(Main.java:27)' – 2013-10-28 20:30:40

+0

我已經添加com.gasstation.main.Main.start –

+0

是否'SRC \\ com \\ gasstation \\ views \\ main-layout.fxml'存在,它是一個有效的JavaFX文件嗎? – 2013-10-28 20:39:11

回答

0

嘗試Parent fxmlRoot = (Parent) loader.load(new FileInputStream(new File("src\com\gasstation\views\main-layout.fxml")));