A Task Which Returns No Value
import javafx.application.Application;
import javafx.concurrent.Task;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) {
Group root = new Group();
Scene scene = new Scene(root, 300, 150);
stage.setScene(scene);
stage.setTitle("Sample");
Task<Void> task = new Task<Void>() {
@Override protected Void call() throws Exception {
return null;
}
};
task.run();
System.out.println(task.getMessage());
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Related examples in the same category