O'Reilly logo

JavaFX 2.0: Introduction by Example by Carl Dea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

1-11. Creating and Working with Observable Lists

Problem

You want to create a GUI application containing two list view controls allowing the user pass items between the two lists.

Solution

Take advantage of JavaFX’s javafx.collections.ObservableList and javafx.scene.control.ListView classes to provide a model-view-controller (MVC) mechanism that updates the UI’s list view control whenever the back-end list is manipulated.

The following code creates a GUI application containing two lists that allow the user to send items contained in one list to be sent to the other. Here you will create a contrived application to pick candidates to be considered heroes. The user will pick potential candidates from the list on the left to be moved into the list ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required