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

JavaFX – setVisible hides the element but doesn’t rearrange adjacent nodes

Node.setVisible(boolean) just toggles the visibility state of a Node. To exclude a Node from its parents layout calculations you additionally have to set its managed state, by calling Node.setManaged(false). If you want the managed state to be updated automatically alongside the visibility, you can use a binding as @jewelsea pointed out: node.managedProperty().bind(node.visibleProperty());

How to get stage from controller during initialization?

You can get the instance of the controller from the FXMLLoader after initialization via getController(), but you need to instantiate an FXMLLoader instead of using the static methods then. I’d pass the stage after calling load() directly to the controller afterwards: FXMLLoader loader = new FXMLLoader(getClass().getResource(“MyGui.fxml”)); Parent root = (Parent)loader.load(); MyController controller = (MyController)loader.getController(); controller.setStageAndSetupListeners(stage); … Read more

What is the recommended way to make a numeric TextField in JavaFX?

Very old thread, but this seems neater and strips out non-numeric characters if pasted. // force the field to be numeric only textField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (!newValue.matches(“\\d*”)) { textField.setText(newValue.replaceAll(“[^\\d]”, “”)); } } });

Error: JavaFX runtime components are missing, and are required to run this application with JDK 11 [duplicate]

This worked for me: File >> Project Structure >> Modules >> Dependency >> + (on left-side of window) clicking the “+” sign will let you designate the directory where you have unpacked JavaFX’s “lib” folder. Scope is Compile (which is the default.) You can then edit this to call it JavaFX by double-clicking on the … Read more

Is it possible to run JavaFX applications on iOS, Android or Windows Phone 8?

Yes you can run JavaFX application on iOS, android, desktop, RaspberryPI (no windows8 mobile yet). Work in Action : We did it! JavaFX8 multimedia project on iPad, Android, Windows and Mac! JavaFX Everywhere Ensemble8 Javafx8 Android Demo My Sample JavaFX application Running on Raspberry Pi My Sample Application Running on Android JavaFX on iOS and … 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

JavaFX Application Icon

Assuming your stage is “stage” and the file is on the filesystem: stage.getIcons().add(new Image(“file:icon.png”)); As per the comment below, if it’s wrapped in a containing jar you’ll need to use the following approach instead: stage.getIcons().add(new Image(<yourclassname>.class.getResourceAsStream(“icon.png”)));