2017-08-17 8 views
0

.fxmlファイルをリンクできません。 また、私はjavaを使い慣れていないし、物事をリンクする方法などを理解していない。 もちろん私はGoogleの答えを探してみましたが、遠くには行きませんでした。URLを.fxmlに設定する

これは

public class loadingWindowTest extends Application{ 

public static void main(String[] args){ 
    launch(args); 
} 

@Override 
public void start(Stage loadingWindowStage) throws Exception { 
    try{ 
     FXMLLoader loadLoadingWindow = new FXMLLoader(); 
     loadLoadingWindow.setLocation(getClass().getResource("de.skullbro.pong.windows.loadingWindow.loadingWindow.fxml")); 
     loadLoadingWindow.setController("de.skullbro.pong.windows.loadingWindow.loadingWindowController"); 
     Parent root = loadLoadingWindow.load(); 

     Scene scene = new Scene(root,(getSystemInformation.screenWidth * 0.5), (getSystemInformation.screenHeight * 0.5)); 

     loadingWindowStage.setScene(scene); 
     loadingWindowStage.show();   
    } 
    catch(Exception e){ 
     if(debug.DebugInformation()){ 
      Alert alert = new Alert(AlertType.ERROR); 
      alert.setTitle("Fehler"); 
      alert.setHeaderText(""); 
      alert.setContentText(e.toString()); 
      alert.show();    
     } 
     else{ 
      Alert alert = new Alert(AlertType.ERROR); 
      alert.setTitle("Upps..."); 
      alert.setHeaderText("Something went wrong."); 
      alert.setContentText("Please try to restart your Game. If this doesn't fix it contact the Developers"); 
      alert.show(); 
     } 
    } 

}} 

私のエラーは私のファイルです: Loactionは私が間違っているのは何

に設定されていませんか? 私は私のloadingWindow.setlocation()についてはよく分からない


もこの作業を行います。ここ

loadLoadingWindow.setLocation(getClass().getResource("de/skullbro/pong/windows/loadingWindow/loadingWindow.fxml")); 

とは私の木の画像です

mytree in eclipse

そして、彼女は私が得ているError nullpointerexceptionです:

java.lang.NullPointerException 
at de.skullbro.pong.windows.loadingWindow.loadingWindowTest.start(loadingWindowTest.java:26) 
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) 
at java.lang.Thread.run(Unknown Source) 
+0

'はgetClass()のgetResource(" /:。だから、あなたが変更されることがあり

をあなたのクラスパス/ jarファイル内にfxmlが含まれていることを確認してください。 – fabian

答えて

1

getResource()パッケージのパスではなく、リスト見込ん:

loadLoadingWindow.setLocation(getClass().getResource("loadingWindow.fxml")); 

Linked to

+0

私たち[tを続行してくださいチャットで彼の議論](http://chat.stackoverflow.com/rooms/152228/discussion-between-azro-and-daneubi)。 – azro

関連する問題