Class ListTile

  • All Implemented Interfaces:
    Styleable, EventTarget

    public class ListTile
    extends BorderPane

    ListTile is a convenient container, similar to an HBox, that can be used as the graphic within a ListCell. Typically, a graphic node will be placed on the left, one or two lines of text will be laid out in the center, and a second graphic node will be on the right.

    Example

    The following example sets a Cell Factory on a CharmListView called headerListView. That cell factory, creates custom instances of CharmListCell, in those instances a ListTile is set as the graphic.

     headerListView.setCellFactory(p -> new CharmListCell<Session>() {
    
      @Override 
       public void updateItem(Session item, boolean empty) {
         super.updateItem(item, empty);
         if (item != null && !empty) {
           VBox buttons = new VBox(MaterialDesignIcon.STAR_BORDER.graphic());
           buttons.setMaxHeight(Double.MAX_VALUE);
           buttons.setAlignment(Pos.TOP_RIGHT);
           ListTile tile = new ListTile();
           tile.textProperty().setAll(item.toString());
           tile.setSecondaryGraphic(buttons);
           tile.setPrefHeight(40);
           tile.setOnMouseClicked(e -> buttons.getChildren().setAll(MaterialDesignIcon.STAR.graphic()));
           setText(null);
           setGraphic(tile);
         } else {
           setText(null);
           setGraphic(null);
         }
       }
       
     });
    
     

    An image of the cells containing the ListTiles follows:

    Screenshot of Cells

    Since:
    1.0.0
    • Constructor Detail

      • ListTile

        public ListTile()
        Empty constructor. Creates a new ListTile, where graphics and text are added through the different properties.
    • Method Detail

      • getPrimaryGraphic

        public final Node getPrimaryGraphic()
        Gets the value of the property primaryGraphic.
        Property description:
        The property to display on the left side of the ListTile, as a full height Node.
      • setPrimaryGraphic

        public final void setPrimaryGraphic​(Node graphic)
        Sets the value of the property primaryGraphic.
        Property description:
        The property to display on the left side of the ListTile, as a full height Node.
      • textProperty

        public final ObservableList<String> textProperty()
        The text to display in the ListTile, each item goes on a separate line. Only the first 3 Strings are used.
      • setTextLine

        public void setTextLine​(int i,
                                String v)
        Set a single line of text. The other lines are unaffected. In case there is no line i yet, empty lines will be added if necessary and line i will be created with the supplied text.
        Parameters:
        i - the index of the line (0 being the first line).
        v - the text that should replace the old text, if any.
      • getSecondaryGraphic

        public final Node getSecondaryGraphic()
        Gets the value of the property secondaryGraphic.
        Property description:
        The property to display on the right side of the ListTile, as a smaller Node.
      • setSecondaryGraphic

        public final void setSecondaryGraphic​(Node graphic)
        Sets the value of the property secondaryGraphic.
        Property description:
        The property to display on the right side of the ListTile, as a smaller Node.
      • wrapTextProperty

        public final BooleanProperty wrapTextProperty()
        A boolean property that indicates whether the text lines should be wrapped onto another line or not if they exceed the width of the ListTile. The default value is false, and the text lines exceeding the width will be truncated
        Since:
        4.0.0
        See Also:
        isWrapText(), setWrapText(boolean)
      • isWrapText

        public final boolean isWrapText()
        Gets the value of the property wrapText.
        Property description:
        A boolean property that indicates whether the text lines should be wrapped onto another line or not if they exceed the width of the ListTile. The default value is false, and the text lines exceeding the width will be truncated
        Since:
        4.0.0
      • setWrapText

        public final void setWrapText​(boolean value)
        Sets the value of the property wrapText.
        Property description:
        A boolean property that indicates whether the text lines should be wrapped onto another line or not if they exceed the width of the ListTile. The default value is false, and the text lines exceeding the width will be truncated
        Since:
        4.0.0