Error with fxml file in JavaFX

0

I have the following error:

java.lang.IllegalStateException: Location is not set.
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
    at userrecognition.Main.start(Main.java:33)
    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(Thread.java:745)


The error marks it in the following line

FXMLLoader loader = new FXMLLoader(getClass().getResource("JFXoverlay.fxml"));


The Fxml file is as follows:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.CheckBox?>

<BorderPane prefHeight="517.0" prefWidth="546.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="userrecognition.FXController">
   <top>
        <VBox>
   <children>
            <HBox alignment="CENTER" spacing="10">
                <padding>
                    <Insets bottom="10" top="10" />
                </padding>
      <children>
                    <CheckBox fx:id="haarClassifier" onAction="#haarSelected" text="Haar Classifier" />
                    <CheckBox fx:id="lbpClassifier" onAction="#lbpSelected" text="LBP Classifier" />
      </children>
            </HBox>
            <Separator />
   </children>
        </VBox>
    </top>
    <center>
        <VBox alignment="CENTER">
            <padding>
                <Insets left="10" right="10" />
            </padding>
   <children>
            <ImageView fx:id="originalFrame" />
   </children>
        </VBox>
    </center>
    <bottom>
        <HBox alignment="CENTER">
            <padding>
                <Insets bottom="25" left="25" right="25" top="25" />
            </padding>
   <children>
            <Button fx:id="cameraButton" alignment="center" disable="true" onAction="#startCamera" text="Start camera" />
            <CheckBox fx:id="newUser" onAction="#newUserSelected" text="New user">
               <HBox.margin>
                  <Insets left="40.0" />
               </HBox.margin>
            </CheckBox>
            <TextField fx:id="newUserName" prefHeight="25.0" prefWidth="130.0" promptText="Enter your name">
               <HBox.margin>
                  <Insets left="20.0" />
               </HBox.margin>
            </TextField>
            <Button fx:id="newUserNameSubmit" onAction="#newUserNameSubmitted" text="Submit">
               <HBox.margin>
                  <Insets left="20.0" />
               </HBox.margin>
            </Button>
   </children>
        </HBox>
    </bottom>
</BorderPane>
    
asked by FrEqDe 10.05.2017 в 17:22
source

1 answer

0

That error is thrown because it does not find the path where the JFXoverlay.fxml file is.

You have to check the route well

FXMLLoader loader = new FXMLLoader (getClass (). getResource ("??????");

    
answered by 10.05.2017 в 22:39