Switching main and background threads in JavaFX made easy.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/main/java/de/sebastianstenzel
.gitignore
LICENSE
README.md
pom.xml

README.md

FXThreads

Switching main and background threads in JavaFX made easy.

This project consists of a single class, thus the easiest way of integrating it is by copying it to your project and maybe rename the package.

Example 1

// get some string from a remote server:
Future<String> futureBookName = runOnBackgroundThread(restResource::getBookName);

// when done, update text label:
runOnMainThreadWhenFinished(futureBookName, (bookName) -> {
  myLabel.setText(bookName);
});

Example 2

// get some string from a remote server:
Future<String> futureBookName = runOnBackgroundThread(restResource::getBookName);

// when done, update text label:
runOnMainThreadWhenFinished(futureBookName, (bookName) -> {
  myLabel.setText(bookName);
}, (exception) -> {
  myLabel.setText("An exception occured: " + exception.getMessage());
});

Usage

FXThreads is available via JitPack:

<repository>
  <id>jitpack.io</id>
  <url>https://jitpack.io</url>
</repository>
<!-- ... -->
<dependency>
  <groupId>com.github.totalvoidness</groupId>
  <artifactId>FXThreads</artifactId>
  <version>1.0</version>
</dependency>

License

Distributed under the MIT license. See the LICENSE file for more info.