Java Reference
In-Depth Information
String potential
= candidatesListView.getSelectionModel().getSelectedItem();
if (potential != null) {
candidatesListView.getSelectionModel().clearSelection();
candidates.remove(potential);
heroes.add(potential);
}
});
When setting an action, you implement an
EventHandler
via a lambda expres-
sion to listen for a button press event. When a button press event arrives, the code will
determine which item in the
ListView
was selected. Once the item was determined,
you clear the selection, remove the item, and add the item to the hero's
Observ-
ableList
.
14-11. Generating a Background Process
Problem
You want to create a GUI application that simulates a long-running process using back-
ground processing while displaying the progress to the users.
Solution
Create an application typical of a dialog box that shows the progress indicators while
copying files in the background. The following are the main classes used in this recipe:
•
javafx.scene.control.ProgressBar
•
javafx.scene.control.ProgressIndicator
•
javafx.concurrent.Task
classes
The following source code is an application that simulates a file copy dialog box
displaying progress indicators and performing background processes: