Skip to content

Instantly share code, notes, and snippets.

@james-d
james-d / MockServer.java
Created February 18, 2016 14:15
Example of showing an alert from background thread using `Platform.runLater(...)`
import static javafx.beans.binding.Bindings.when;
import java.util.Random;
import java.util.function.Consumer;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
@jewelsea
jewelsea / H2Tasks.java
Last active March 5, 2024 22:24
Sample for accessing a local database from JavaFX using concurrent tasks for database operations so that the UI remains responsive.
package h2app;
import javafx.application.Application;
import javafx.collections.*;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;
@jewelsea
jewelsea / ServiceTest.java
Created May 23, 2012 10:29
JavaFX Service example
import javafx.animation.*;
import javafx.application.Application;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.*;
import javafx.concurrent.*;
import javafx.event.*;
import javafx.geometry.*;
import javafx.scene.Scene;
@jewelsea
jewelsea / TaskBasedSplash.java
Last active February 26, 2024 13:33
Displays a JavaFX splash page for an intensive startup task with progress monitoring
import javafx.animation.FadeTransition;
import javafx.application.Application;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.collections.*;
import javafx.concurrent.*;
import javafx.geometry.*;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.*;