2017-06-20 9 views
-1

で新しいウィンドウを開くことができません。 これは多くのエラーを示します。 しかし、私は彼のオープンノーマル "openPlanes"を削除します。 javafx.fxml.LoadException:指定なしコントローラによって引き起こさボタン "onAction"に "openPlanes"メソッドを入れると、JavaFX

@FXML 
    private void openPlanes() { 
     openStage("view/Cadastro.fxml"); 
    } 

private void openStage(String fxml) { 
     try { 
      Stage currentStage = (Stage) PLANE.getScene().getWindow(); 
      Parent root = FXMLLoader.load(getClass().getResource(fxml)); 
      Scene scene = new Scene(root); 
      Stage stage = new Stage(StageStyle.TRANSPARENT); 
      stage.setScene(scene); 
      stage.show(); 
      currentStage.hide(); 

     } catch (IOException ex) { 
      Logger.getLogger(mainController.class.getName()).log(Level.SEVERE, null, ex); 
     } 

    } 

enter image description here

。 ファイル:/ C:!/Users/diego/Documents/NetBeansProjects/Automekanik/DGDSoft/dist/run708547813/DGD%20Soft.jar /dgdsoft/view/MainDGD.fxml:23

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597) 
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103) 
at javafx.fxml.FXMLLoader$Element.getControllerMethodHandle(FXMLLoader.java:557) 
at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:599) 
at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770) 
at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532) 
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 dgdsoft.DGDSoft.start(DGDSoft.java:19) 
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 

例外実行中のアプリケーションdgdsoft .DGDSoft Javaの結果:1

+0

エラーは何ですか? 'openStage(...)とは何ですか? –

+0

私はこの男のアプリケーション GitHubで分析した - 私はhttps://www.youtube.com/watch?v=ooT0Ueyngeo - https://github.com/mlayah/bookingFX/tree/master/src/bookingfx YouTubeにより多くを学ぶためにいくつかの等しい部分を作った、私はいくつかを修正しようとしました。 2番目のウィンドウを呼び出そうとしましたが、このエラーとこのコードは理解できませんでした。 –

+0

"コントローラが指定されていません"は、FXMLファイルでコントローラクラスを指定しなかったことを意味します。 –

答えて

0

まず、ロードしようとしているfxmlリソースが、期待するディレクトリにあることを確認します。適切なディレクトリにある場合は、fxmlファイルを開き、文字列fx:controllerを検索します。 コントローラが記載されたパッケージの内側にあることを確認してください。

あなたは、文字列のFX見つからない場合は、次のFXMLファイルやコードを提出、

private Scene getScene(String fxmlPath, ControllerClass controller) { 
     FXMLLoader loader; 
     Parent parent; 
     Scene scene; 
     try { 
      //not FXMLLoader.load(getClass().getResource(fxmlPath) 
      loader = new FXMLLoader(getClass().getResource(fxmlPath)); 
      loader.setController(controller); 
      parent = loader.load(); 
     } catch (Exception e) { 
      e.printStackTrace(); 
      return null; 
     } 
     scene = new Scene(parent); 

     return scene; 

    } 

最後に:FXMLファイルでコントローラを、あなたはとしてプログラム的にそれを行う必要があります。

関連する問題