Guten Tag,
ich habe gerad erst angefangen mich mit JavaFX zu beschäftigen und bin deshalb gerade ein wenig überfordert.
Ich versuche eine absolut rudimentäre GUI zu erzeugen, was mit dem exakt gleichen Code auch schon funktioniert hat.
Seit ich allerdings ein neues Projekt begonnen und den Code rüber kopiert habe, bekomme ich jedoch jedes Mal eine Fehlermeldg und und die Main lässt sich nicht ausführen.
Ich hatte das gleiche Problem schon beim vorherigen Mal und habe es durch rumprobieren eher zufällig gelöst.
Das klappt diesmal leider nicht und ich würde gerne verstehen wo das Problem liegt.
Das ist der Java-Code:
Der Fehler liegt ziemlich sicher bzw. offensichtlicht in der hervorgehobenen Zeile, ich weiß jedoch nicht wie er behoben wird.
[CODE lang="java" highlight="37"]package application;
import java.io.File;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
HBox parent = FXMLLoader.load(new File("demo2.xml").toURI().toURL());
primaryStage.setScene(new Scene(parent));
primaryStage.show();
}
}[/CODE]
der XML-Code
Und die Fehlermeldung:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
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$1(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
/D:/workspace/TestJavaFXBorders/demo2.xml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
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:20)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(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$4(WinApplication.java:185)
... 1 more
Caused by: java.lang.UnsupportedOperationException: Cannot determine type for property.
at com.sun.javafx.fxml.BeanAdapter.getSetterMethod(BeanAdapter.java:177)
at com.sun.javafx.fxml.BeanAdapter.isReadOnly(BeanAdapter.java:305)
at javafx.fxml.FXMLLoader$PropertyElement.<init>(FXMLLoader.java:1368)
at javafx.fxml.FXMLLoader.createElement(FXMLLoader.java:2731)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2704)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
... 17 more
Exception running application application.Main
Vielen Dank im Voraus für eure Hilfe.
ich habe gerad erst angefangen mich mit JavaFX zu beschäftigen und bin deshalb gerade ein wenig überfordert.
Ich versuche eine absolut rudimentäre GUI zu erzeugen, was mit dem exakt gleichen Code auch schon funktioniert hat.
Seit ich allerdings ein neues Projekt begonnen und den Code rüber kopiert habe, bekomme ich jedoch jedes Mal eine Fehlermeldg und und die Main lässt sich nicht ausführen.
Ich hatte das gleiche Problem schon beim vorherigen Mal und habe es durch rumprobieren eher zufällig gelöst.
Das klappt diesmal leider nicht und ich würde gerne verstehen wo das Problem liegt.
Das ist der Java-Code:
Der Fehler liegt ziemlich sicher bzw. offensichtlicht in der hervorgehobenen Zeile, ich weiß jedoch nicht wie er behoben wird.
[CODE lang="java" highlight="37"]package application;
import java.io.File;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
HBox parent = FXMLLoader.load(new File("demo2.xml").toURI().toURL());
primaryStage.setScene(new Scene(parent));
primaryStage.show();
}
}[/CODE]
der XML-Code
XML:
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.control.TextArea?>
<HBox>
<left>
<Button>
<text>
Text für Button
</text>
</Button>
</left>
<rigth>
<TextField>
<text>
Text für Textfield
</text>
</TextField>
</rigth>
<center>
<TextArea>
</TextArea>
</center>
<bottom>
<Slider>
</Slider>
</bottom>
</HBox>
Und die Fehlermeldung:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
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$1(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
/D:/workspace/TestJavaFXBorders/demo2.xml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
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:20)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(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$4(WinApplication.java:185)
... 1 more
Caused by: java.lang.UnsupportedOperationException: Cannot determine type for property.
at com.sun.javafx.fxml.BeanAdapter.getSetterMethod(BeanAdapter.java:177)
at com.sun.javafx.fxml.BeanAdapter.isReadOnly(BeanAdapter.java:305)
at javafx.fxml.FXMLLoader$PropertyElement.<init>(FXMLLoader.java:1368)
at javafx.fxml.FXMLLoader.createElement(FXMLLoader.java:2731)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2704)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
... 17 more
Exception running application application.Main
Vielen Dank im Voraus für eure Hilfe.