I want to program after the Model View Controller Concept in my JavaFX
application and so I coded the launch method into my view package in the GUI class. Here you can see my GUI Class:
public class GUIFalscherName extends Application {
// Komplexe Datentypen
//*********************************//
VBox elternteil;
Label testLabel;
//*********************************//
public GUIFalscherName(String[] args) {
GUIFalscherName.launch(args);
}
public void start(Stage buehne) throws Exception {
buehne.setTitle("Test");
this.elternteil = new VBox();
this.testLabel = new Label();
this.testLabel.setText("test");
fuegeKomponenteDemParentHinzu(testLabel);
Scene scene = new Scene(elternteil);
buehne.setScene(scene);
buehne.show();
}
public void fuegeKomponenteDemParentHinzu(Node komponente) {
this.elternteil.getChildren().add(komponente);
}
}
Here you can see my main class from where I want to call the constructor of the GUI class where the launch is to launch the GUI.
public class FalscherName {
public static void main(String[] args) {
GUIFalscherName guiFalscherName = new GUIFalscherName(args);
}
}
So my goal is to tear the main part apart from the GUI part and to not mix them, as the Model View Controller Concept says.
However, when I run my code I get the following error:
Exception in Application constructor
Exception in thread "main" java.lang.RuntimeException: Unable to construct Application instance: class de.falschername.view.GUIFalscherName
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:907)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodException: de.falschername.view.GUIFalscherName.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$7(LauncherImpl.java:818)
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:186)
... 1 more
What's going wrong here?