Class CardPane<T>

  • Type Parameters:
    T - This type is used to represent the type of the objects stored in the CardPane's getItems() items} ObservableList.
    All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    @DefaultProperty("items")
    public class CardPane<T>
    extends Control

    CardPane is a container of cards. Any node can be added to this container as a card and will be laid out vertically, taking all available width. The content of CardPane is scrollable.

    By default, cards are styled according to the Material Design guidelines.

    Example

    The following example illustrates the usage of the CardPane class.

     CardPane cardPane = new CardPane();
     cardPane.getItems().addAll( label("Card 1"), label("Card 2"), label("Card 3"));
    
     private Label label( String caption ) {
       Label label = new Label( caption );
       label.setStyle("-fx-padding:10;");
       return label;
     }
     

    Screenshot of CardPane

    The CardPane is prepared for a big number of items by reusing its cards.

    A developer may personalize cell creation by specifying a cell factory through cellFactoryProperty(). The default cell factory is prepared to accept objects from classes that extend Node or other classes that don't extend from Node, in the latter case the card text will be given by the Object.toString() implementation of the object.

    For more information refer to the cellFactory property documentation.

    Since:
    4.2.0
    See Also:
    CardCell
    • Property Detail

      • cellFactory

        public final ObjectProperty<Callback<CardPane<T>,​CardCell<T>>> cellFactoryProperty

        The cell factory. Each cell corresponds to a card. Setting a cell factory allows the developer to personalize cell creation, which allows for total customization of the cell. In this case the developer typically sets the items property with the items in the data model and then modifies the cell, which might later be reused, according to the data model item that is to be shown on that cell.

        Setting a new cell factory forces all old CardCells to be thrown away and new CardCells created with the new cell factory.

        Default value:
        Cell factory that accepts Nodes in the items property. It also accepts other classes that don't extend from Node, in that case the text in the card will be given by the Object.toString() implementation of the object.
        See Also:
        getCellFactory(), setCellFactory(Callback)
    • Constructor Detail

      • CardPane

        public CardPane()
        The constructor for CardPane.
    • Method Detail

      • getItems

        public final ObservableList<T> getItems()
        The list of items to be shown. This could be the collection of items of the data model or a collection of Nodes to be directly shown inside the card.
        Returns:
        the list of items.
      • cellFactoryProperty

        public final ObjectProperty<Callback<CardPane<T>,​CardCell<T>>> cellFactoryProperty()

        The cell factory. Each cell corresponds to a card. Setting a cell factory allows the developer to personalize cell creation, which allows for total customization of the cell. In this case the developer typically sets the items property with the items in the data model and then modifies the cell, which might later be reused, according to the data model item that is to be shown on that cell.

        Setting a new cell factory forces all old CardCells to be thrown away and new CardCells created with the new cell factory.

        Default value:
        Cell factory that accepts Nodes in the items property. It also accepts other classes that don't extend from Node, in that case the text in the card will be given by the Object.toString() implementation of the object.
        See Also:
        getCellFactory(), setCellFactory(Callback)
      • setCellFactory

        public final void setCellFactory​(Callback<CardPane<T>,​CardCell<T>> factory)
        Sets the value of the property cellFactory.
        Property description:

        The cell factory. Each cell corresponds to a card. Setting a cell factory allows the developer to personalize cell creation, which allows for total customization of the cell. In this case the developer typically sets the items property with the items in the data model and then modifies the cell, which might later be reused, according to the data model item that is to be shown on that cell.

        Setting a new cell factory forces all old CardCells to be thrown away and new CardCells created with the new cell factory.

        Default value:
        Cell factory that accepts Nodes in the items property. It also accepts other classes that don't extend from Node, in that case the text in the card will be given by the Object.toString() implementation of the object.
      • getCellFactory

        public final Callback<CardPane<T>,​CardCell<T>> getCellFactory()
        Gets the value of the property cellFactory.
        Property description:

        The cell factory. Each cell corresponds to a card. Setting a cell factory allows the developer to personalize cell creation, which allows for total customization of the cell. In this case the developer typically sets the items property with the items in the data model and then modifies the cell, which might later be reused, according to the data model item that is to be shown on that cell.

        Setting a new cell factory forces all old CardCells to be thrown away and new CardCells created with the new cell factory.

        Default value:
        Cell factory that accepts Nodes in the items property. It also accepts other classes that don't extend from Node, in that case the text in the card will be given by the Object.toString() implementation of the object.
      • setPlaceholder

        public final void setPlaceholder​(Node node)
        Sets the value of the property placeholder.
        Property description:
        The Node to show in case there are no items in the CardPane.
        Default value:
        null
      • getPlaceholder

        public Node getPlaceholder()
        Gets the value of the property placeholder.
        Property description:
        The Node to show in case there are no items in the CardPane.
        Default value:
        null
      • setOnPullToRefresh

        public final void setOnPullToRefresh​(EventHandler<ActionEvent> eventHandler)
        Sets the value of the property onPullToRefresh.
        Property description:

        The EventHandler to be called whenever there's a Swipe Refresh. This EventHandler will run on a background thread.

        To enable pull to refresh set a handler for this property.

        Default value:
        null
      • getOnPullToRefresh

        public final EventHandler<ActionEvent> getOnPullToRefresh()
        Gets the value of the property onPullToRefresh.
        Property description:

        The EventHandler to be called whenever there's a Swipe Refresh. This EventHandler will run on a background thread.

        To enable pull to refresh set a handler for this property.

        Default value:
        null