.jar not running, but it is running in netbeans

时间:2017-05-16 09:19:24

标签: java

We made a schoolproject which included some .fxml files, but the program is running in netbeans, and it runs the .jar; But or scenes are not loaded in.

We thought the problem is because of a bad path to or .fxml files, but we don't know what it should be then.

Thanks in advance

Or start method

  @Override
public void start(Stage primaryStage) {

    SceneController mainContainer = new SceneController();

    mainContainer.setLanguague(2);

    //mainContainer.loadScreen(Main.screen1ID, Main.screen1File);
    mainContainer.loadScreen(Main.screen2ID, Main.screen2File);
    //mainContainer.loadScreen(Main.screen3ID, Main.screen3File);
    //mainContainer.loadScreen(Main.screen4ID, Main.screen4File);
    //mainContainer.loadScreen(Main.screen5ID, Main.screen5File);
    mainContainer.loadScreen(Main.screen8ID, Main.screen8File); //intro
    //mainContainer.loadScreen(Main.screen9ID, Main.screen9File);
    //mainContainer.loadScreen(Main.screen11ID, Main.screen11File);

   // mainContainer.loadScreen(Main.screen7ID, Main.screen7File);

    //beginscherm:
    mainContainer.setScreen(Main.screen8ID); //8

    Group root = new Group();
    root.getChildren().addAll(mainContainer);
    Scene scene = new Scene(root);

Or loadScreen method

public boolean loadScreen(String name, String resource) {

    try {

        //loader
        FXMLLoader loader = new FXMLLoader(getClass().getResource(resource));
        System.out.println(getClass().getResource(name));
        System.out.println("loader");
        loader.setResources(rs);
        System.out.println("resources");
        Parent loadScreen = (Parent) loader.load();
         System.out.println("loadscreen");
        _Scene sceneControler = ((_Scene) loader.getController());
         System.out.println("controller");
        sceneControler.setScreenParent(this);
        addScreen(name, loadScreen);

        //
        return true;

    } catch (Exception e) {

        System.out.println(e.getMessage());

        return false;
    }
}

These are the scenes we are using

public static String screen1ID = "MainMenu";
public static String screen1File = "scenes/fxml/MainMenu.fxml";
public static String screen2ID = "Language";
public static String screen2File = "scenes/fxml/Language.fxml";
public static String screen3ID = "Settings";
public static String screen3File = "scenes/fxml/Settings.fxml";
public static String screen4ID = "Register";
public static String screen4File = "scenes/fxml/Register.fxml";
public static String screen5ID = "Credits";
public static String screen5File = "scenes/fxml/Credits.fxml";
public static String screen6ID = "SideDeck";
public static String screen6File = "scenes/fxml/SideDeck.fxml";
public static String screen7ID = "Game";
public static String screen7File = "scenes/fxml/Game.fxml";
public static String screen8ID = "Intro";
public static String screen8File = "scenes/fxml/Intro.fxml";
public static String screen9ID = "Shop";
public static String screen9File = "scenes/fxml/Shop.fxml";
public static String screen10ID = "Message";
public static String screen10File = "scenes/fxml/Message.fxml";
public static String screen11ID = "SelectPlayer";
public static String screen11File = "scenes/fxml/SelectPlayer.fxml";
public static String screen12ID = "LoadGame";
public static String screen12File = "scenes/fxml/LoadGame.fxml";
public static String screen13ID = "ShowPlayers";
public static String screen13File = "scenes/fxml/ShowPlayers.fxml";

0 个答案:

没有答案