Java Reference
In-Depth Information
ColumnConstraints constraints1 = new ColumnConstraints();
constraints1.setHalignment(HPos.CENTER);
constraints1.setMinWidth(65);
ColumnConstraints constraints2 = new ColumnConstraints();
constraints2.setHalignment(HPos.LEFT);
constraints2.setMinWidth(200);
GridPane centerPane = new GridPane();
centerPane.setHgap(10);
centerPane.setVgap(10);
centerPane.setPadding(new Insets(10, 10, 10, 10));
centerPane.getColumnConstraints()
.addAll(constraints1, constraints2);
centerPane.add(new Label("Title:"), 0, 0);
centerPane.add(new Label("Message:"), 0, 1);
centerPane.add(new Label("Running:"), 0, 2);
centerPane.add(new Label("State:"), 0, 3);
centerPane.add(new Label("Total Work:"), 0, 4);
centerPane.add(new Label("Work Done:"), 0, 5);
centerPane.add(new Label("Progress:"), 0, 6);
centerPane.add(new Label("Value:"), 0, 7);
centerPane.add(new Label("Exception:"), 0, 8);
centerPane.add(title, 1, 0);
centerPane.add(message, 1, 1);
centerPane.add(running, 1, 2);
centerPane.add(state, 1, 3);
centerPane.add(totalWork, 1, 4);
centerPane.add(workDone, 1, 5);
centerPane.add(progress, 1, 6);
centerPane.add(value, 1, 7);
centerPane.add(exception, 1, 8);
HBox buttonPane = new HBox(10,
startButton, cancelButton, exceptionButton);
buttonPane.setPadding(new Insets(10, 10, 10, 10));
buttonPane.setAlignment(Pos.CENTER);
BorderPane root = new BorderPane(centerPane,
topPane, null, buttonPane, null);
scene = new Scene(root);
}
}
}
The Model nested class for this program holds a worker field of type Worker , and a shouldThrow field of type
AtomicBoolean . The worker field is initialized to an instance of an anonymous subclass of Task<String> that
implements its call() method by simulating the processing of 250 items at a 20-milliseconds-per-item pace. It
updates the properties of the task at the beginning of the call and in each iteration of the loop. It handles cancellation
 
Search WWH ::




Custom Search