List of usage examples for javafx.concurrent Task getMessage
@Override public final String getMessage()
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 300, 150); stage.setScene(scene);/* ww w. j a va2 s. c o m*/ 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(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 300, 150); stage.setScene(scene);// w ww . ja va2 s. com stage.setTitle("Sample"); Task<ObservableList<String>> task = new Task<ObservableList<String>>() { @Override protected ObservableList<String> call() throws Exception { updateMessage("message"); ObservableList<String> results = FXCollections.observableArrayList(); for (int i = 0; i < 10; i++) { if (isCancelled()) break; results.add(""); updateProgress(i, 100); } return results; } }; task.run(); System.out.println(task.getMessage()); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 300, 150); stage.setScene(scene);//from w w w . j a v a 2 s .c o m stage.setTitle("Sample"); Task<Integer> task = new Task<Integer>() { @Override protected Integer call() throws Exception { int iterations; for (iterations = 0; iterations < 10000000; iterations++) { if (isCancelled()) { updateMessage("Cancelled"); break; } updateMessage("Iteration " + iterations); updateProgress(iterations, 10000000); } return iterations; } }; task.run(); System.out.println(task.getMessage()); // root.getChildren().add(t); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 300, 150); stage.setScene(scene);//from w w w .ja v a 2 s . c om stage.setTitle("Sample"); final int totalIterations = 90; Task<Integer> task = new Task<Integer>() { @Override protected Integer call() throws Exception { int iterations; for (iterations = 0; iterations < totalIterations; iterations++) { if (isCancelled()) { updateMessage("Cancelled"); break; } updateMessage("Iteration " + iterations); updateProgress(iterations, totalIterations); } return iterations; } }; task.run(); System.out.println(task.getMessage()); // root.getChildren().add(t); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { final Group group = new Group(); Scene scene = new Scene(group, 300, 150); stage.setScene(scene);//from w ww. j a va 2s.c om stage.setTitle("Sample"); Task<Void> task = new Task<Void>() { @Override protected Void call() throws Exception { for (int i = 0; i < 10; i++) { if (isCancelled()) break; final Rectangle r = new Rectangle(10, 10); r.setX(10 * i + i); Platform.runLater(new Runnable() { @Override public void run() { group.getChildren().add(r); } }); } return null; } }; task.run(); System.out.println(task.getMessage()); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 300, 150); stage.setScene(scene);/* w w w .j av a2 s.c om*/ stage.setTitle("Sample"); Task<Integer> task = new Task<Integer>() { @Override protected Integer call() throws Exception { int iterations; for (iterations = 0; iterations < 10; iterations++) { if (isCancelled()) { updateMessage("Cancelled"); break; } updateMessage("Iteration " + iterations); updateProgress(iterations, 1000); try { Thread.sleep(100); } catch (InterruptedException interrupted) { if (isCancelled()) { updateMessage("Cancelled"); break; } } } return iterations; } }; task.run(); System.out.println(task.getMessage()); // root.getChildren().add(t); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { final Group group = new Group(); Scene scene = new Scene(group, 300, 150); stage.setScene(scene);//from w w w .j a va2 s .c om stage.setTitle("Sample"); Task<Integer> task = new Task<Integer>() { @Override protected Integer call() throws Exception { int iterations = 0; for (iterations = 0; iterations < 10; iterations++) { if (isCancelled()) { break; } System.out.println("Iteration " + iterations); } return iterations; } @Override protected void succeeded() { super.succeeded(); updateMessage("Done!"); } @Override protected void cancelled() { super.cancelled(); updateMessage("Cancelled!"); } @Override protected void failed() { super.failed(); updateMessage("Failed!"); } }; task.run(); System.out.println(task.getMessage()); stage.show(); }