Class AvatarPane<T>

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

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

    The AvatarPane contains a collection of Avatars on the top, over a content Node. Typically the content being shown is a description of the corresponding selected Avatar, the user selects an Avatar by clicking/tapping that Avatar.

    An items property exists to hold the collection of items from a data model. For the creation of each Avatar the programmer must set an Avatar factory, the Avatar factory receives an item and should create an Avatar based on that item. A content factory, with a return type of Node, is also needed to populate the content beneath the Avatars.

    Example

    The following example creates an AvatarPane containing a list of speakers. Sets the Avatar factory with a factory that returns an Avatar with speaker.getPicture() as the Image URL, and sets a content factory that returns a vertical list containing speaker.getFullName(), speaker.getJobTitle(), speaker.getCompany() and speaker.getSummary().

     
     AvatarPane<Speaker> avatarPane = new AvatarPane<>(speakers);
     avatarPane.setAvatarFactory(speaker -> {
       Avatar avatar = new Avatar();
       Image image = new Image(speaker.getPicture());
       avatar.setImage(image);
       return avatar;
     });
     avatarPane.setContentFactory(speaker -> {
       VBox container = new VBox();
       Label name = new Label(speaker.getFullName());
       name.setWrapText(true);
       Label jobTitle = new Label(speaker.getJobTitle());
       jobTitle.setWrapText(true);
       Label company = new Label(speaker.getCompany());
       company.setWrapText(true);
       Label summary = new Label(speaker.getSummary());
       summary.setWrapText(true);
       container.getChildren().addAll(name, jobTitle, company, summary);
       return container;
     });
     
     
    Since:
    4.2.0
    See Also:
    Avatar
    • Constructor Detail

      • AvatarPane

        public AvatarPane()
        The default constructor, creates an empty AvatarPane with no items.
      • AvatarPane

        public AvatarPane​(ObservableList<T> items)
        Creates an AvatarPane with the items passed in as a parameter. By default the first item is the selected item.
        Parameters:
        items - The items to be included in this AvatarPane.
    • Method Detail

      • getItems

        public final ObservableList<T> getItems()
        Gets the value of the property items.
        Property description:
        The list of items to be shown in this AvatarPane.
      • setItems

        public final void setItems​(ObservableList<T> items)
        Sets the value of the property items.
        Property description:
        The list of items to be shown in this AvatarPane.
      • getAvatarFactory

        public final Callback<T,​Avatar> getAvatarFactory()
        Gets the value of the property avatarFactory.
        Property description:
        For every item in the AvatarPane the avatar factory is called to get the Avatar to be placed with the other Avatars on the top.
      • setAvatarFactory

        public final void setAvatarFactory​(Callback<T,​Avatar> value)
        Sets the value of the property avatarFactory.
        Property description:
        For every item in the AvatarPane the avatar factory is called to get the Avatar to be placed with the other Avatars on the top.
      • getContentFactory

        public final Callback<T,​Node> getContentFactory()
        Gets the value of the property contentFactory.
        Property description:
        For every item in the AvatarPane the content factory is called to get the content Node to show below the corresponding Avatar.
      • setContentFactory

        public final void setContentFactory​(Callback<T,​Node> value)
        Sets the value of the property contentFactory.
        Property description:
        For every item in the AvatarPane the content factory is called to get the content Node to show below the corresponding Avatar.
      • getValue

        public final T getValue()
        Gets the value of the property value.
        Property description:
        The selected item. The selected item changes as the user taps/clicks on an Avatar.
      • setValue

        public final void setValue​(T value)
        Sets the value of the property value.
        Property description:
        The selected item. The selected item changes as the user taps/clicks on an Avatar.
      • expandedProperty

        public final BooleanProperty expandedProperty()
        Whether the content should be expanded. If set to true the content will be visible, otherwise it will not.
        Default value:
        true
        See Also:
        isExpanded(), setExpanded(boolean)
      • setExpanded

        public final void setExpanded​(boolean value)
        Sets the value of the property expanded.
        Property description:
        Whether the content should be expanded. If set to true the content will be visible, otherwise it will not.
        Default value:
        true
      • isExpanded

        public final boolean isExpanded()
        Gets the value of the property expanded.
        Property description:
        Whether the content should be expanded. If set to true the content will be visible, otherwise it will not.
        Default value:
        true
      • setCollapsible

        public final void setCollapsible​(boolean value)
        Sets the value of the property collapsible.
        Property description:
        If set to true the AvatarPane may be expanded or collapsed (refer to expandedProperty()) by the user by pressing the currently selected Avatar.
        Default value:
        false
      • isCollapsible

        public final boolean isCollapsible()
        Gets the value of the property collapsible.
        Property description:
        If set to true the AvatarPane may be expanded or collapsed (refer to expandedProperty()) by the user by pressing the currently selected Avatar.
        Default value:
        false
      • getExitAction

        public final Runnable getExitAction()
        Gets the value of the property exitAction.
        Property description:
      • setExitAction

        public final void setExitAction​(Runnable value)
        Sets the value of the property exitAction.
        Property description: