Fehler Meldung beim Anzeigen von einer FXML?

3 Antworten

Und hier noch der FXML Code:

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

<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<AnchorPane fx:id="parent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" style="-fx-background-color: white;" styleClass="parent" stylesheets="@../css/loginstyle.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mein.pfad.fxml.MainUIController">
   <children>
      <VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #b1b1b1b1;">
         <children>
            <ImageView fitHeight="102.0" fitWidth="369.0" pickOnBounds="true" smooth="false">
               <image>
                  <Image url="@../image/logo.png" />
               </image>
               <VBox.margin>
                  <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
               </VBox.margin>
            </ImageView>
         </children>
      </VBox>
      <Pane layoutX="400.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #FFF;">
         <children>
            <Label layoutX="42.0" layoutY="102.0" text="Welcome Back," textFill="#403f3f">
               <font>
                  <Font name="Impact" size="25.0" />
               </font>
            </Label>
            <Label layoutX="42.0" layoutY="134.0" text="Sign in to continue" textFill="#a3a3a3">
               <font>
                  <Font name="Calibri Bold" size="16.0" />
               </font>
            </Label>
            <JFXTextField focusColor="#3c3939" labelFloat="true" layoutX="58.0" layoutY="251.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="35.0" prefWidth="300.0" promptText="Email" unFocusColor="#7c7b7b">
               <font>
                  <Font size="14.0" />
               </font>
            </JFXTextField>
            <JFXPasswordField focusColor="#3c3939" labelFloat="true" layoutX="58.0" layoutY="307.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="35.0" prefWidth="300.0" promptText="Password" unFocusColor="#7c7b7b">
               <font>
                  <Font size="14.0" />
               </font>
            </JFXPasswordField>
            <Label layoutX="243.0" layoutY="361.0" styleClass="forgetBtn" text="Forget Password?" textFill="#949191">
               <font>
                  <Font name="Calibri" size="16.0" />
               </font>
            </Label>
            <JFXButton buttonType="RAISED" layoutX="58.0" layoutY="397.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="50.0" prefWidth="300.0" ripplerFill="#686363" styleClass="loginBtn" text="Login">
               <font>
                  <Font name="System Bold" size="14.0" />
               </font>
            </JFXButton>
            <Label layoutX="135.0" layoutY="480.0" text="New User?" textFill="#949191">
               <font>
                  <Font name="Calibri" size="16.0" />
               </font>
            </Label>
            <Label layoutX="212.0" layoutY="480.0" onMouseClicked="#open_registration" text="Signup" textFill="#494949">
               <font>
                  <Font name="Calibri" size="16.0" />
               </font>
               <cursor>
                  <Cursor fx:constant="HAND" />
               </cursor>
            </Label>
            <FontAwesomeIcon iconName="CLOSE" layoutX="379.0" layoutY="20.0" onMouseClicked="#close_app" size="1.5em" stroke="WHITE" styleClass="closeBtn" />
         </children>
      </Pane>
   </children>
</AnchorPane>


Fehler:

Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: Location is required.
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
    at website.builder.WebsiteBuilder.start(WebsiteBuilder.java:26)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(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$147(WinApplication.java:177)
    ... 1 more
Exception running application website.builder.WebsiteBuilder

Ich würde mal sagen, die FXML-Datei kann nicht gefunden werden.

Prüfe, ob die Datei im Ressourcen-Ordner (resources/fxml) liegt und versuche es, wenn das nicht hilft, einmal über den ClassLoader:

Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("/fxml/login.fxml"));

Letzteres ist ein Problem, welches von der IDE verursacht wird, da die FXML-Dateien beim Bauen möglicherweise nicht in den richtigen Ordner verschoben werden.

HKM17 
Fragesteller
 01.12.2019, 10:05

Ohne JFoenix Elemente öffnet sich die UI.Es liegt an den JFoenix Elementen.

0
HKM17 
Fragesteller
 05.12.2019, 19:48
@regex9

Diese beiden Sachen gehören zusammen.Das habe ich mittlerweile raus gefunden. Ein paar mal funktioniert es, dann plötzlich nicht mehr.

0