JavaFX controller class not working

Don’t make the Application class a controller. It’s a sin. There are other questions and answers which address this, but my search skills cannot find them at this time. The reason it is a sin is: You are only supposed to have one Application instance, and, by default, the loader will make a new instance, … Read more

Loading new fxml in the same scene

Why your code does not work The loader creates a new AnchorPane, but you never add the new pane to a parent in the scene graph. Quick Fix Instead of: content = (AnchorPane) FXMLLoader.load(“vista2.fxml”); Write: content.getChildren().setAll(FXMLLoader.load(“vista2.fxml”)); Replacing the content children with your new vista. The content itself remains in the scene graph, so when you … Read more

JavaFX and OpenJDK

JavaFX is part of OpenJDK The JavaFX project itself is open source and is part of the OpenJDK project. However, the OpenJDK project includes many projects, including incubating projects and other projects, such as OpenJFX, whose source and implementation are not shipped as part of some JDK/JRE distributions (e.g. Oracle JDK 11+ implementations and many … Read more

Module error when running JavaFx media application

TL;DR: You need to make sure javafx.media is resolved as a module from the module-path. You can do this by either: Including it in the VM arguments: –add-modules javafx.controls,javafx.media Or making your own code modular, adding an appropriate requires javafx.media; directive to your module descriptor, and using –module to launch your application. If you’re not … Read more

Platform.runLater and Task in JavaFX

Use Platform.runLater(…) for quick and simple operations and Task for complex and big operations . Use case for Platform.runLater(…) Use case for Task: Task Example in Ensemble App Example: Why Can’t we use Platform.runLater(…) for long calculations (Taken from below reference). Problem: Background thread which just counts from 0 to 1 million and update progress … Read more