ListView
Displays a list of items vertically inside a ScrollPane.
Each visible item in the list is displayed using a ListCell. By default, cellFactory creates TextListCells, whose text is each items value converted to a string using Any.toString. However, you can create a custom cellFactory, which creates any ListCells containing whatever you need.
There are only ever enough ListCells for the visible items. For example, if items.size
== 100, but only 10 fit within the ListView's bounds, then there be 10 ListCells, and as you scroll, the same 10 ListCells will be reused, and their contents will be updated to reflect the data within the items.
If type T is mutable, then the cellFactory must bind
to the item's properties, to ensure that mutating the data is reflected in the ListCell.
Currently, all cells must be the same height, which is governed by fixedCellSize. and if this is <= 0, then the first cell's prefHeight
is used instead.
Theme DSL
"list_view" {
"fixedCellSize"( float )
descendant("list_cell") {
":odd" { ... }
":even" { ... }
// The selected row of the listView.
":selected" { ... }
}
}
Properties
When set, items in the ListView can be reordered by dragging with the mouse, and also using Ctrl+Up / Down. The default value is false
.
The base class Node has no children, so this is an empty list.
Functions
Find the index of value
within items, using ===
as the test. This is different from List.indexOf, which uses equals()
rather than ===
. Therefore List.indexOf would find the wrong item if there are more than one item in the list that met the equals()
test.
By default, ListViews have an arbitrary prefHeight. Set evalPrefHeight, or add the ListView to a layout control which will allocate a sensible area regardless of evalPrefWidth.
By default, ListViews have an arbitrary prefWidth. Set evalPrefWidth, or add the ListView to a layout control which will allocate a sensible area regardless of evalPrefWidth.