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.fxml.LoadException: unknown path

( ͡° ͜ʖ ͡°)
Joined
Mar 30, 2015
Messages
2,416
Trying to follow the guide here Tutorial - JavaFX for Beginners for setting up a GUI, but I'm running into a Load Exception saying unknown path pointing to
final Parent root = loader.load(vWestFiremaker.class.getResourceAsStream("practice.fxml"));
in my practiceGui class and
Platform.runLater(() -> new practiceGui(this));
in my main class. Can't seem to figure this out as the getResourceAsStream is finding the practice.fxml file under the same package as the main class (which is where it should be finding it). When running the bot, a white box pops up as if it's trying to load the GUI but then I get the unknown path error. I've looked at a few stackOverflow posts and some say the error could be because I don't have a no arguments constructor in my controller class, but the tut didn't have any in theirs? Help pls am nub

The whole error output:
Code:
javafx.fxml.LoadException:
unknown path

   at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
   at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
   at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
   at com.deathizpro.bots.vWestFiremaker.practiceGui.<init>(practiceGui.java:18)
   at com.deathizpro.bots.vWestFiremaker.vWestFiremaker.lambda$onStart$0(vWestFiremaker.java:53)
   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(Thread.java:745)
Caused by: java.lang.NullPointerException
   at com.deathizpro.bots.vWestFiremaker.practiceController.initialize(practiceController.java:21)
   at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
   ... 10 more

Here is the GUI setup:
Code:
public class practiceGui extends Stage {

    public practiceGui(vWestFiremaker script) {
        try {
            FXMLLoader loader = new FXMLLoader();

            loader.setController(new practiceController(script, this));

            final Parent root = loader.load(vWestFiremaker.class.getResourceAsStream("practice.fxml"));

            final Scene scene = new Scene(root);

            setTitle("vWestFires");

            setScene(scene);
        } catch (IOException e) {
            e.printStackTrace();
        }

        show();
    }
}

The fxml file for the gui that I'm trying to create:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="249.0" prefWidth="389.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Button fx:id="startButton" layoutX="150.0" layoutY="155.0" mnemonicParsing="false" prefHeight="43.0" prefWidth="90.0" text="Start" />
      <Label contentDisplay="CENTER" layoutX="92.0" layoutY="77.0" prefHeight="25.0" prefWidth="74.0" text="Log Type:" />
      <ComboBox fx:id="logChoice" layoutX="165.0" layoutY="77.0" prefWidth="150.0" />
   </children>
</AnchorPane>

and how I start it in the main class:
Code:
public void onStart(String... args) {
    Platform.runLater(() -> new practiceGui(this));
}
 
Added a bit more info on what exactly is happening.
 
Joined
Apr 30, 2016
Messages
16
You should be using embeddedUI.

You can see how you can do that here: Tutorial - Implementing Embeddable UI

Other than that;

Code:
// Load the fxml file using RuneMate's Resources class.
        FXMLLoader loader = new FXMLLoader();

        // Input your GUI FXML file location here.
        // NOTE: DO NOT FORGET TO ADD IT TO MANIFEST AS A RESOURCE
        Future<InputStream> stream = bot.getPlatform().invokeLater(() -> Resources.getAsStream("com/deathispro/bots/bot/uipath"));

        // Set controller and root
        loader.setController(new PracticeController(script, this);
        loader.setRoot(this);

        try {
            loader.load(stream.get());
        } catch (IOException | InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
 
( ͡° ͜ʖ ͡°)
Joined
Mar 30, 2015
Messages
2,416
For this line here:
Code:
        Future<InputStream> stream = bot.getPlatform().invokeLater(() -> Resources.getAsStream("com/deathispro/bots/bot/uipath"));

What exactly goes at the bot.getPlatform().invokeLater. Is the bot.getPlatform() supposed to be replaced with my main bot class? When I do that I get a "nonstatic method getPlatform() cannot be referenced from a nonstatic method.
 
I've also tried using the EmbeddableUI Tutorial and get the same Unknown Path error.
 
Joined
Apr 30, 2016
Messages
16
ah sorry forgot about having that part in there.
You either need to take your main script as a parameter or find another way to get your main script. I can't remember how but there's another way ^^
It's easiest to just parse it though. That way your gui can also talk to your bot if needed.
 
Top