Servis-Rhino 4211B Guia do Utilizador Página 270

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 298
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 269
JavaFX ListView
The ListView is a container for a list of items. If there are more items in the list than can be
shown, the list scrolls.
The items in the list can be set through the list's "items" property which is an instance of an
"ObservableList".
If we want to know which item in the list is selected, we can ask the list of its selection model and
from that model ask for the selected index or selected item.
For example:
list.getSelectonModel().getSelectedIndex();
If we want to know when a selection changes, we can use the "selectedItemProperty" of the
selection model and add a listener to it.
list.getSelectionModel().selectedItemProperty().addListener(new ChangeListener …);
The ChangeListener has a method called changed:
changed(Observable<? extends T> observable, T oldValue, T newValue)
The visualization for an entry in the list is controlled by the "CellFactory". This is a property
on the List that can be set. JavaFX provides some existing instances including:
CheckBoxCellList
ChoiceBoxCellList
ComboBoxCellList
TextFieldCellList
The default visualization of a list entry is simply the string representation of the item contained
within. We can define our own visualizer using the "setCellFactory()" method. This
method takes a Callback() object that must return an instance of a ListCell object. It is this
object that is the visualization and describes how to show data.
See also:
JavaFX ObservableList
JavaFX MultipleSelectionModel - How items are selected
JavaFX ListView Tutorial - 8
JavaFX PasswordField
The PasswordField widget is a text entry box which hides the characters typed.
JavaFX ProgressBar
The ProgressBar widget shows the progress of some activity.
Page 270
Vista de página 269
1 2 ... 265 266 267 268 269 270 271 272 273 274 275 ... 297 298

Comentários a estes Manuais

Sem comentários