Class ComboBoxListCell<T>

Type Parameters:
T - The type of the elements contained within the ListView.
All Implemented Interfaces:
Styleable, EventTarget, Skinnable

public class ComboBoxListCell<T>
extends ListCell<T>
A class containing a ListCell implementation that draws a ComboBox node inside the cell.

By default, the ComboBoxListCell is rendered as a Label when not being edited, and as a ComboBox when in editing mode. The ComboBox will, by default, stretch to fill the entire list cell.

To create a ComboBoxListCell, it is necessary to provide zero or more items that will be shown to the user when the ComboBox menu is showing. These items must be of the same type as the ListView items sequence, such that upon selection, they replace the existing value in the items list.

Since:
JavaFX 2.2
  • Property Details

  • Constructor Details

    • ComboBoxListCell

      public ComboBoxListCell()
      Creates a default ComboBoxListCell with an empty items list.
    • ComboBoxListCell

      @SafeVarargs public ComboBoxListCell​(T... items)
      Creates a default ComboBoxListCell instance with the given items being used to populate the ComboBox when it is shown.
      Parameters:
      items - The items to show in the ComboBox popup menu when selected by the user.
    • ComboBoxListCell

      @SafeVarargs public ComboBoxListCell​(StringConverter<T> converter, T... items)
      Creates a ComboBoxListCell instance with the given items being used to populate the ComboBox when it is shown, and the StringConverter being used to convert the item in to a user-readable form.
      Parameters:
      converter - A StringConverter that can convert an item of type T into a user-readable string so that it may then be shown in the ComboBox popup menu.
      items - The items to show in the ComboBox popup menu when selected by the user.
    • ComboBoxListCell

      public ComboBoxListCell​(ObservableList<T> items)
      Creates a default ComboBoxListCell instance with the given items being used to populate the ComboBox when it is shown.
      Parameters:
      items - The items to show in the ComboBox popup menu when selected by the user.
    • ComboBoxListCell

      public ComboBoxListCell​(StringConverter<T> converter, ObservableList<T> items)
      Creates a ComboBoxListCell instance with the given items being used to populate the ComboBox when it is shown, and the StringConverter being used to convert the item in to a user-readable form.
      Parameters:
      converter - A StringConverter that can convert an item of type T into a user-readable string so that it may then be shown in the ComboBox popup menu.
      items - The items to show in the ComboBox popup menu when selected by the user.
  • Method Details

    • forListView

      @SafeVarargs public static <T> Callback<ListView<T>,​ListCell<T>> forListView​(T... items)
      Creates a ComboBox cell factory for use in ListView controls. By default, the ComboBoxCell is rendered as a Label when not being edited, and as a ComboBox when in editing mode. The ComboBox will, by default, stretch to fill the entire list cell.
      Type Parameters:
      T - The type of the elements contained within the ListView.
      Parameters:
      items - Zero or more items that will be shown to the user when the ComboBox menu is showing. These items must be of the same type as the ListView items list, such that upon selection, they replace the existing value in the items list.
      Returns:
      A Callback that will return a ListCell that is able to work on the type of element contained within the ListView.
    • forListView

      @SafeVarargs public static <T> Callback<ListView<T>,​ListCell<T>> forListView​(StringConverter<T> converter, T... items)
      Creates a ComboBox cell factory for use in ListView controls. By default, the ComboBoxCell is rendered as a Label when not being edited, and as a ComboBox when in editing mode. The ComboBox will, by default, stretch to fill the entire list cell.
      Type Parameters:
      T - The type of the elements contained within the ListView.
      Parameters:
      converter - A StringConverter to convert the given item (of type T) to a String for displaying to the user.
      items - Zero or more items that will be shown to the user when the ComboBox menu is showing. These items must be of the same type as the ListView items list, such that upon selection, they replace the existing value in the items list.
      Returns:
      A Callback that will return a ListCell that is able to work on the type of element contained within the ListView.
    • forListView

      public static <T> Callback<ListView<T>,​ListCell<T>> forListView​(ObservableList<T> items)
      Creates a ComboBox cell factory for use in ListView controls. By default, the ComboBoxCell is rendered as a Label when not being edited, and as a ComboBox when in editing mode. The ComboBox will, by default, stretch to fill the entire list cell.
      Type Parameters:
      T - The type of the elements contained within the ListView.
      Parameters:
      items - An ObservableList containing zero or more items that will be shown to the user when the ComboBox menu is showing. These items must be of the same type as the ListView items sequence, such that upon selection, they replace the existing value in the items list.
      Returns:
      A Callback that will return a ListCell that is able to work on the type of element contained within the ListView.
    • forListView

      public static <T> Callback<ListView<T>,​ListCell<T>> forListView​(StringConverter<T> converter, ObservableList<T> items)
      Creates a ComboBox cell factory for use in ListView controls. By default, the ComboBoxCell is rendered as a Label when not being edited, and as a ComboBox when in editing mode. The ComboBox will, by default, stretch to fill the entire list cell.
      Type Parameters:
      T - The type of the elements contained within the ListView.
      Parameters:
      converter - A StringConverter to convert the given item (of type T) to a String for displaying to the user.
      items - An ObservableList containing zero or more items that will be shown to the user when the ComboBox menu is showing. These items must be of the same type as the ListView items sequence, such that upon selection, they replace the existing value in the items list.
      Returns:
      A Callback that will return a ListCell that is able to work on the type of element contained within the ListView.
    • converterProperty

      public final ObjectProperty<StringConverter<T>> converterProperty()
      The StringConverter property.
      See Also:
      getConverter(), setConverter(StringConverter)
    • setConverter

      public final void setConverter​(StringConverter<T> value)
      Sets the StringConverter to be used in this cell.
      Parameters:
      value - the StringConverter to be used in this cell
    • getConverter

      public final StringConverter<T> getConverter()
      Returns the StringConverter used in this cell.
      Returns:
      the StringConverter used in this cell
    • comboBoxEditableProperty

      public final BooleanProperty comboBoxEditableProperty()
      A property representing whether the ComboBox, when shown to the user, is editable or not.
      See Also:
      isComboBoxEditable(), setComboBoxEditable(boolean)
    • setComboBoxEditable

      public final void setComboBoxEditable​(boolean value)
      Configures the ComboBox to be editable (to allow user input outside of the options provide in the dropdown list).
      Parameters:
      value - the editable value for this ComboBox
    • isComboBoxEditable

      public final boolean isComboBoxEditable()
      Returns true if the ComboBox is editable.
      Returns:
      true if the ComboBox is editable
    • getItems

      public ObservableList<T> getItems()
      Returns the items to be displayed in the ChoiceBox when it is showing.
      Returns:
      the items to be displayed in the ChoiceBox when it is showing