May 2018
Intermediate to advanced
268 pages
6h 43m
English
The ListView content is backed up by an ObservableList and any changes to this list are automatically reflected in the ListView, as in the button handler in the next example:
// chaptep10/list/ListViewDemo.javaObservableList<String> items = FXCollections.observableArrayList( "Red", "Blue", "Yellow", "Green");ListView<String> list = new ListView<>(items);Button btn = new Button("Add New Item");btn.setOnAction((e) -> { items.add( // just a way to generate semirandom new items items.get(new Random().nextInt(items.size())) );});
Read now
Unlock full access