Hallo erstmal,
Ich hab viel mit Swing gemacht und wollte jetzt umsteigen auf JavaFX, bin also ziemlicher Anfänger.
Jedoch habe ich ein Problem beim Laden meine FXML Datei. Ich habe sämtliche Namen überprüft, daran dürfte es nicht liegen. Für den Pfad habe ich es auch mal mit einem absoluten versucht, hat auch nichts gebracht.
Mein Programm:
Parent root = FXMLLoader.load(getClass().getResource("TextInPicture.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
Die FXML Datei:
<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="460.0" prefWidth="600.0" type="Accordion" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<panes>
<TitledPane contentDisplay="CENTER" text="Programm Infos">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label alignment="CENTER" layoutX="24.0" layoutY="20.0" prefHeight="50.0" prefWidth="550.0" text="Hide and unhide a secret message in a picture!" underline="true">
<font>
<Font size="25.0" />
</font>
</Label>
<Label layoutX="188.0" layoutY="60.0" text="programmed by Linus Dierheimer" />
<TextArea cacheHint="QUALITY" depthTest="DISABLE" editable="false" layoutX="91.0" layoutY="101.0" mouseTransparent="true" prefHeight="202.0" prefWidth="418.0" text="This programm is made to hide a secret message in a picture, or to unhide it. It is even abel to compare two pictures, if their sourcecode is absolutely idently to look if there is a message in one of them. For use one of this effects, just press one of the botton below!" wrapText="true">
<opaqueInsets>
<Insets />
</opaqueInsets>
<font>
<Font size="17.0" />
</font>
</TextArea>
<AmbientLight color="CHARTREUSE" layoutX="546.0" layoutY="20.0" lightOn="true" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane contentDisplay="CENTER" text="Hide a message">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label layoutX="25.0" layoutY="35.0" text="The path of the picture, thats copy will be used for hide the message:" />
<TextField fx:id="textfelt1Hide" alignment="CENTER" layoutX="25.0" layoutY="56.0" prefHeight="31.0" prefWidth="550.0" />
<Label layoutX="25.0" layoutY="97.0" />
<Label layoutX="25.0" layoutY="97.0" text="The path of the new picture:" />
<TextField fx:id="textfeld2Hide" layoutX="25.0" layoutY="118.0" prefHeight="31.0" prefWidth="550.0" />
<Button fx:id="buttonHide" layoutX="255.0" layoutY="162.0" mnemonicParsing="false" text="OK!" textAlignment="CENTER" />
<ProgressBar fx:id="balkenHide" layoutX="25.0" layoutY="238.0" prefHeight="23.0" prefWidth="548.0" progress="0.0" />
<Label layoutX="25.0" layoutY="208.0" prefHeight="21.0" prefWidth="550.0" text="fortschritt" visible="false" />
<Label fx:id="fortschrittHide" contentDisplay="TOP" layoutX="25.0" layoutY="219.0" prefHeight="21.0" prefWidth="550.0" text="fortschritt" textAlignment="CENTER" />
<Label layoutX="277.0" layoutY="261.0" />
<AmbientLight color="CHARTREUSE" layoutX="544.0" layoutY="14.0" lightOn="true" />
</children></AnchorPane>
</content>
</TitledPane>
<TitledPane alignment="TOP_LEFT" contentDisplay="CENTER" text="read a message">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label layoutX="24.0" layoutY="27.0" prefHeight="21.0" prefWidth="550.0" text="The path of the picture with the message:" />
<TextField fx:id="textfeldread" layoutX="24.0" layoutY="48.0" prefHeight="31.0" prefWidth="550.0" />
<Button fx:id="buttonRead" layoutX="267.0" layoutY="96.0" mnemonicParsing="false" text="OK!" />
<Label fx:id="fortschrittRead" layoutX="24.0" layoutY="117.0" prefHeight="21.0" prefWidth="550.0" text="fortschritt" />
<ProgressBar fx:id="balkenRead" layoutX="25.0" layoutY="138.0" prefHeight="23.0" prefWidth="549.0" progress="0.0" />
<TextArea fx:id="paneRead" layoutX="25.0" layoutY="168.0" prefHeight="157.0" prefWidth="550.0" />
<AmbientLight color="CHARTREUSE" layoutX="536.0" layoutY="27.0" lightOn="true" />
</children></AnchorPane>
</content>
</TitledPane>
<TitledPane contentDisplay="CENTER" text="compare two pics">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label layoutX="25.0" layoutY="20.0" prefHeight="21.0" prefWidth="545.0" text="The path of the first picture to be compared:" />
<TextField fx:id="textfeld1Comp" layoutX="24.0" layoutY="41.0" prefHeight="31.0" prefWidth="550.0" />
<Label layoutX="24.0" layoutY="85.0" text="The path of the second picture:" />
<TextField fx:id="textfeld2comp" layoutX="25.0" layoutY="106.0" prefHeight="31.0" prefWidth="550.0" />
<Button fx:id="buttonComp" layoutX="268.0" layoutY="146.0" mnemonicParsing="false" text="OK!" />
<Label fx:id="fortschrittComp" layoutX="25.0" layoutY="184.0" prefHeight="21.0" prefWidth="550.0" text="fortschritt" />
<ProgressBar fx:id="balkenComp" layoutX="24.0" layoutY="205.0" prefHeight="23.0" prefWidth="550.0" progress="0.0" />
<Label fx:id="ergebnisComp" alignment="CENTER" layoutX="25.0" layoutY="243.0" prefHeight="21.0" prefWidth="550.0" text="Ergebnis" textAlignment="CENTER" />
<AmbientLight color="CHARTREUSE" layoutX="542.0" layoutY="20.0" lightOn="true" />
</children></AnchorPane>
</content>
</TitledPane>
</panes>
</fx:root>
Und die Fehlermeldung:
javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load.
/C:/Users/Linus/Documents/Programieren/Java/Programme/messageInPicture/bin/application/TextInPicture.fxml:11
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$RootElement.constructValue(FXMLLoader.java:1326)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:746)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
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 application.Main.start(Main.java:15)
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(Unknown Source)
Ich hab viel mit Swing gemacht und wollte jetzt umsteigen auf JavaFX, bin also ziemlicher Anfänger.
Jedoch habe ich ein Problem beim Laden meine FXML Datei. Ich habe sämtliche Namen überprüft, daran dürfte es nicht liegen. Für den Pfad habe ich es auch mal mit einem absoluten versucht, hat auch nichts gebracht.
Mein Programm:
Parent root = FXMLLoader.load(getClass().getResource("TextInPicture.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
Die FXML Datei:
<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="460.0" prefWidth="600.0" type="Accordion" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<panes>
<TitledPane contentDisplay="CENTER" text="Programm Infos">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label alignment="CENTER" layoutX="24.0" layoutY="20.0" prefHeight="50.0" prefWidth="550.0" text="Hide and unhide a secret message in a picture!" underline="true">
<font>
<Font size="25.0" />
</font>
</Label>
<Label layoutX="188.0" layoutY="60.0" text="programmed by Linus Dierheimer" />
<TextArea cacheHint="QUALITY" depthTest="DISABLE" editable="false" layoutX="91.0" layoutY="101.0" mouseTransparent="true" prefHeight="202.0" prefWidth="418.0" text="This programm is made to hide a secret message in a picture, or to unhide it. It is even abel to compare two pictures, if their sourcecode is absolutely idently to look if there is a message in one of them. For use one of this effects, just press one of the botton below!" wrapText="true">
<opaqueInsets>
<Insets />
</opaqueInsets>
<font>
<Font size="17.0" />
</font>
</TextArea>
<AmbientLight color="CHARTREUSE" layoutX="546.0" layoutY="20.0" lightOn="true" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane contentDisplay="CENTER" text="Hide a message">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label layoutX="25.0" layoutY="35.0" text="The path of the picture, thats copy will be used for hide the message:" />
<TextField fx:id="textfelt1Hide" alignment="CENTER" layoutX="25.0" layoutY="56.0" prefHeight="31.0" prefWidth="550.0" />
<Label layoutX="25.0" layoutY="97.0" />
<Label layoutX="25.0" layoutY="97.0" text="The path of the new picture:" />
<TextField fx:id="textfeld2Hide" layoutX="25.0" layoutY="118.0" prefHeight="31.0" prefWidth="550.0" />
<Button fx:id="buttonHide" layoutX="255.0" layoutY="162.0" mnemonicParsing="false" text="OK!" textAlignment="CENTER" />
<ProgressBar fx:id="balkenHide" layoutX="25.0" layoutY="238.0" prefHeight="23.0" prefWidth="548.0" progress="0.0" />
<Label layoutX="25.0" layoutY="208.0" prefHeight="21.0" prefWidth="550.0" text="fortschritt" visible="false" />
<Label fx:id="fortschrittHide" contentDisplay="TOP" layoutX="25.0" layoutY="219.0" prefHeight="21.0" prefWidth="550.0" text="fortschritt" textAlignment="CENTER" />
<Label layoutX="277.0" layoutY="261.0" />
<AmbientLight color="CHARTREUSE" layoutX="544.0" layoutY="14.0" lightOn="true" />
</children></AnchorPane>
</content>
</TitledPane>
<TitledPane alignment="TOP_LEFT" contentDisplay="CENTER" text="read a message">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label layoutX="24.0" layoutY="27.0" prefHeight="21.0" prefWidth="550.0" text="The path of the picture with the message:" />
<TextField fx:id="textfeldread" layoutX="24.0" layoutY="48.0" prefHeight="31.0" prefWidth="550.0" />
<Button fx:id="buttonRead" layoutX="267.0" layoutY="96.0" mnemonicParsing="false" text="OK!" />
<Label fx:id="fortschrittRead" layoutX="24.0" layoutY="117.0" prefHeight="21.0" prefWidth="550.0" text="fortschritt" />
<ProgressBar fx:id="balkenRead" layoutX="25.0" layoutY="138.0" prefHeight="23.0" prefWidth="549.0" progress="0.0" />
<TextArea fx:id="paneRead" layoutX="25.0" layoutY="168.0" prefHeight="157.0" prefWidth="550.0" />
<AmbientLight color="CHARTREUSE" layoutX="536.0" layoutY="27.0" lightOn="true" />
</children></AnchorPane>
</content>
</TitledPane>
<TitledPane contentDisplay="CENTER" text="compare two pics">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label layoutX="25.0" layoutY="20.0" prefHeight="21.0" prefWidth="545.0" text="The path of the first picture to be compared:" />
<TextField fx:id="textfeld1Comp" layoutX="24.0" layoutY="41.0" prefHeight="31.0" prefWidth="550.0" />
<Label layoutX="24.0" layoutY="85.0" text="The path of the second picture:" />
<TextField fx:id="textfeld2comp" layoutX="25.0" layoutY="106.0" prefHeight="31.0" prefWidth="550.0" />
<Button fx:id="buttonComp" layoutX="268.0" layoutY="146.0" mnemonicParsing="false" text="OK!" />
<Label fx:id="fortschrittComp" layoutX="25.0" layoutY="184.0" prefHeight="21.0" prefWidth="550.0" text="fortschritt" />
<ProgressBar fx:id="balkenComp" layoutX="24.0" layoutY="205.0" prefHeight="23.0" prefWidth="550.0" progress="0.0" />
<Label fx:id="ergebnisComp" alignment="CENTER" layoutX="25.0" layoutY="243.0" prefHeight="21.0" prefWidth="550.0" text="Ergebnis" textAlignment="CENTER" />
<AmbientLight color="CHARTREUSE" layoutX="542.0" layoutY="20.0" lightOn="true" />
</children></AnchorPane>
</content>
</TitledPane>
</panes>
</fx:root>
Und die Fehlermeldung:
javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load.
/C:/Users/Linus/Documents/Programieren/Java/Programme/messageInPicture/bin/application/TextInPicture.fxml:11
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$RootElement.constructValue(FXMLLoader.java:1326)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:746)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
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 application.Main.start(Main.java:15)
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(Unknown Source)