Class ListBox

All Implemented Interfaces:
Animatable<ListBox>, CanDrop<ListBox>, Draggable<ListBox>, HandleMouseEvents<ListBox>, Scrollable<ListBox>

List component

This component displays an ordered or unordered list on the interface. Each item of the ordered list comes with a number before, and the item content is indented. Items of an unordered list are preceded by a dot and the item text is indented.

Not only texts, but also any arbitrary components may be placed in a list component and will be displayed in the above described manner on the interface.

Supported events:

AnimationStart AnimationEnd, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, Scrollable Drop, DragStart, DragEnd

Since:
4.0
Author:
JBStrap
See Also:
  • Constructor Details

    • ListBox

      public ListBox()
      Creates an empty unordered list
    • ListBox

      public ListBox(String id)
      Creates an empty unordered list with the specified ID
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
    • ListBox

      public ListBox(boolean sorted)
      Creates an empty list and sets if the list is ordered or unordered
      Parameters:
      sorted - If a true value is set, the list will be displayed as ordered, otherwise as an unordered list.
    • ListBox

      public ListBox(String id, boolean sorted)
      Creates an empty list and sets if the list is ordered or unordered
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      sorted - If a true value is set, the list will be displayed as ordered, otherwise as an unordered list.
  • Method Details

    • isSorted

      public boolean isSorted()
      Defines whether the list is ordered
      Returns:
      true if the list is ordered otherwise false
    • setSorted

      public ListBox setSorted(boolean sorted)
      Sets if the list is ordered
      Parameters:
      sorted - If true is set, the list is displayed as an ordered list, otherwise as an unordered list
      Returns:
      The list component
    • addTextListItem

      public ListBox addTextListItem(String text)
      Adds a text component to the list as a list item
      Parameters:
      text - Text content to be displayed as a list item
      Returns:
      The list component
    • addItemList

      public ListBox addItemList(List<?> items)
      Adds multiple items to the list Items provided can be textual or components or of both types
      Parameters:
      items - An enumeration of items we want to add to the list If the list item is a component, the given component will be added to the list. If the list item is not a component, a textual representation will be added to the list instead.
      Returns:
      The list component
    • getItems

      public List<ListItem> getItems()
      Gets all items of the list
      Returns:
      An enumeration of items of the List type, with all items being a list item If the list is empty, an empty list is the return value
    • size

      public int size()
      Gets the number of items in the list
      Returns:
      The number of items in the list If the list is empty, the return value is 0
    • addComponent

      public ListBox addComponent(Component<?> component)
      Description copied from class: Component
      Adds the specified component as a subcomponent, and redraws the component immediately
      Overrides:
      addComponent in class Component<ListBox>
      Parameters:
      component - The component to be added
      Returns:
      The component
    • clear

      public final ListBox clear()
      Deletes all items of the list
      Returns:
      The list component
    • removeComponent

      public ListBox removeComponent(Component<?> component)
      Description copied from class: Component
      Removes the specified subcomponent.
      Overrides:
      removeComponent in class Component<ListBox>
      Parameters:
      component - The component instance
      Returns:
      The component
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<ListBox>
      Returns:
      If the componentwas drawn, true, otherwise false