Ich habe ein "normales" Javafx Projekt zu einem maven Porjekt konvertiert, um die Vorteile der Modularisierung zu nutzen.
Nun bekomme ich einen Fehler, wenn ich die fxml Seite wechsle.
[CODE lang="java" highlight="7"]@FXML
private AnchorPane content = new AnchorPane();
@FXML
private Menu diagramOptions;
@FXML
void openSimpleMode(ActionEvent event) throws InvalidFileFormatException, IOException {
diagramOptions.setVisible(true);
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/SimpleMode.fxml"));
Node simpleModePane = null;
try {
simpleModePane = loader.load();
} catch (Exception e) {
System.out.println("error in loading pane");
}
content.getChildren().clear();
content.getChildren().add(simpleModePane);
simplecontroller = loader.getController();
if (simplecontroller != null) {
simplecontroller.initData(ldfParser, methods, this);
} else {
System.out.println("null Pointer exception");
}
System.out.println("error after this");
}[/CODE]
Der Fehler kommt nicht, wenn ich die Zeile:
weglasse.
Das komische ist, dass der Fehler erst nach der ganzen Methode kommt und alles "richtig" geladen und angezeigt wird.
der ganze Error:
als es noch kein maven Projekt war habe ich den Fehler nicht bekommen
Nun bekomme ich einen Fehler, wenn ich die fxml Seite wechsle.
[CODE lang="java" highlight="7"]@FXML
private AnchorPane content = new AnchorPane();
@FXML
private Menu diagramOptions;
@FXML
void openSimpleMode(ActionEvent event) throws InvalidFileFormatException, IOException {
diagramOptions.setVisible(true);
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/SimpleMode.fxml"));
Node simpleModePane = null;
try {
simpleModePane = loader.load();
} catch (Exception e) {
System.out.println("error in loading pane");
}
content.getChildren().clear();
content.getChildren().add(simpleModePane);
simplecontroller = loader.getController();
if (simplecontroller != null) {
simplecontroller.initData(ldfParser, methods, this);
} else {
System.out.println("null Pointer exception");
}
System.out.println("error after this");
}[/CODE]
Der Fehler kommt nicht, wenn ich die Zeile:
Java:
diagramOptions.setVisible(true);
Das komische ist, dass der Fehler erst nach der ganzen Methode kommt und alles "richtig" geladen und angezeigt wird.
der ganze Error:
Java:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "javafx.scene.control.MenuButton.getScene()" because the return value of "javafx.scene.control.skin.MenuButtonSkinBase.getSkinnable()" is null
at javafx.controls/javafx.scene.control.skin.MenuButtonSkinBase.lambda$new$7(MenuButtonSkinBase.java:188)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:832)
als es noch kein maven Projekt war habe ich den Fehler nicht bekommen