Module MaterialFX

Class AbstractMFXListCell<T>

Type Parameters:
T - the type of data within the ListView
All Implemented Interfaces:
io.github.palexdev.virtualizedfx.cell.Cell<T>, Styleable, EventTarget
Direct Known Subclasses:
MFXCheckListCell, MFXListCell

public abstract class AbstractMFXListCell<T> extends HBox implements io.github.palexdev.virtualizedfx.cell.Cell<T>
Base class for all cells used in listviews based on VirtualizedFX, defines common properties and behavior (e.g. selection), has the selected property and PseudoClass ":selected" for usage in CSS.

Extends HBox and implements Cell.

  • Property Details

  • Field Details

  • Constructor Details

  • Method Details

    • render

      protected abstract void render(T data)
      Abstract method which defines how the cell should process and show the given data.
    • initialize

      protected void initialize()
    • setBehavior

      protected void setBehavior()
      Sets the following behaviors:

      - Binds the selected property to the list' selection model (checks for index).

      - Updates the selected PseudoClass state when selected property changes.

      - Adds and handler for MOUSE_PRESSED events to call updateSelection(MouseEvent).

    • updateSelection

      protected void updateSelection(MouseEvent event)
      If the pressed mouse button is not the primary, exits immediately.

      If the cell is already deselected calls MultipleSelectionModel.deselectIndex(int), otherwise checks if Shift or Ctrl are pressed and updates the selection accordingly, adds if they were pressed, replaces if not (acting like single selection), see MultipleSelectionModel.selectIndex(int), MultipleSelectionModel.replaceSelection(Integer...).

    • updateIndex

      public void updateIndex(int index)
      Updates the index property of the cell.

      This is called before updateItem(Object).

      Specified by:
      updateIndex in interface io.github.palexdev.virtualizedfx.cell.Cell<T>
    • updateItem

      public void updateItem(T item)
      Updates the data property of the cell.

      This is called after updateIndex(int).

      Specified by:
      updateItem in interface io.github.palexdev.virtualizedfx.cell.Cell<T>
    • getData

      public T getData()
      Gets the value of the property data.
      Property description:
      Data property of the cell.
    • dataProperty

      public ReadOnlyObjectProperty<T> dataProperty()
      Data property of the cell.
      See Also:
    • setData

      protected void setData(T data)
      Sets the value of the property data.
      Property description:
      Data property of the cell.
    • getIndex

      public int getIndex()
      Gets the value of the property index.
      Property description:
      Specifies the cell's index.
    • indexProperty

      public ReadOnlyIntegerProperty indexProperty()
      Specifies the cell's index.
      See Also:
    • setIndex

      protected void setIndex(int index)
      Sets the value of the property index.
      Property description:
      Specifies the cell's index.
    • isSelected

      public boolean isSelected()
      Gets the value of the property selected.
      Property description:
      Specifies the selection state of the cell.
    • selectedProperty

      public ReadOnlyBooleanProperty selectedProperty()
      Specifies the selection state of the cell.
      See Also:
    • setSelected

      protected void setSelected(boolean selected)
      Sets the value of the property selected.
      Property description:
      Specifies the selection state of the cell.