- Joined
- Mar 30, 2015
- Messages
- 2,416
- Thread Author
- #1
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:
Here is the GUI setup:
The fxml file for the gui that I'm trying to create:
and how I start it in the main class:
Added a bit more info on what exactly is happening.
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.