Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question JavaFX second ui not loading

Joined
Nov 6, 2015
Messages
541
Hi,

I've made 2 UI's with FXML but the problem is it won't load the second one as it properly loads the first one it returns when I click on 'Start bot' it shows this and doens't continue to the next stage..I've tried to make the Node static but that's just a bad fix, anyone knows what I am doing wrong? Yes I also added the resource to the .xml

Code:
Error | java.lang.NullPointerException: inputStream is null.
java.lang.NullPointerException: inputStream is null.
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2455)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
    at com.remco1337.bots.tutorialisland.TutorialIsland.lambda$loadStatusUI$2(TutorialIsland.java:64)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run$$$capture(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$3(WinApplication.java:177)
    at java.lang.Thread.run(Unknown Source)

CODE:

Code:
package com.remco1337.bots.tutorialisland;

import com.remco1337.bots.tutorialisland.ui.TutorialIslandUIStartController;
import com.remco1337.bots.tutorialisland.ui.TutorialIslandUIStatusController;
import com.runemate.game.api.client.embeddable.EmbeddableUI;
import com.runemate.game.api.hybrid.Environment;
import com.runemate.game.api.hybrid.util.Resources;
import com.runemate.game.api.script.framework.tree.TreeBot;
import com.runemate.game.api.script.framework.tree.TreeTask;
import javafx.application.Platform;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;

public class TutorialIsland extends TreeBot implements EmbeddableUI {
    static private ObjectProperty<Node> botInterfaceProperty;
    private Settings setting = Settings.getInstance();

    @Override
    public TreeTask createRootTask() {
        return new DoTutorialIsland();
    }

    @Override
    public void onStart(String... args) {
        setting.onFirstLoad();
    }

    @Override
    public void onPause() {
        setting.pauseScript();
    }

    @Override
    public void onResume() {
        setting.resumeScript();
    }

    @Override
    public void onStop() {
        Platform.runLater(()->{
            try {
                FXMLLoader loader_start = new FXMLLoader();
                Node node_start = loader_start.load(Resources.getAsStream("com/remco1337/bots/tutorialisland/ui/tutorialisland_start_ui.fxml"));
                Platform.runLater(()-> botInterfaceProperty = new SimpleObjectProperty<>(node_start));
                botInterfaceProperty.setValue(node_start);
            }
            catch (Exception e) {
                System.out.println("Error | " + e);
                e.printStackTrace();
            }
        });

        setting.endBot();
    }

    public void loadStatusUI() {
        Platform.runLater(()->{
            System.out.println("loadStatusUI: called!");
            try {
                FXMLLoader loader_status = new FXMLLoader();
                loader_status.setController(new TutorialIslandUIStatusController());
                Node node_status = loader_status.load(Resources.getAsStream("com/remco1337/bots/tutorialisland/ui/tutorialisland_status_ui.fxml")); // ERROR!
                botInterfaceProperty = new SimpleObjectProperty<>(node_status);
                botInterfaceProperty.set(node_status);
                //System.out.println("loadStatusUI: Initalized!" + node_status.isVisible());
            }
            catch (Exception e) {
                System.out.println("Error | " + e);
                e.printStackTrace();
            }
        });
    }

    public TutorialIsland() {
        setEmbeddableUI(this);
    }

    @Override
    public ObjectProperty<Node> botInterfaceProperty() {
        if (botInterfaceProperty == null) {
            FXMLLoader loader_start = new FXMLLoader();
            loader_start.setController(new TutorialIslandUIStartController());
            try {
                Node node_start = loader_start.load(Resources.getAsStream("com/remco1337/bots/tutorialisland/ui/tutorialisland_start_ui.fxml"));
                botInterfaceProperty = new SimpleObjectProperty<>(node_start);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return botInterfaceProperty;
    }
}
 
Top