public void changeScenes(ActionEvent event, String viewName, String title) throws IOException{
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource(viewName));
Parent parent = loader.load();
Scene scene = new Scene(parent);
Stage stage = (Stage)((Node)event.getSource()).getScene().getWindow();
stage.setTitle(title);
stage.setScene(scene);
stage.show();
}
public void saveBreadButtonPushed(ActionEvent event) {
SceneChanger sc = new SceneChanger();
sc.changeScenes(event, "bread.fxml", "List");
Running this saveBreadButtonPushed results in a nullpointerException error. A nullpointerException error occurred in the stage.setTitle(title) line. I'd appreciate it if you could help me.
javafx
(Stage)((Node)event.getSource()).getScene().getWindow();
This means that the return value of that line is null.
It is not known from the code given in part.
You need to try tracing using a debugger.
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.