Class TextListModelTag.TextListModel

  • All Implemented Interfaces:
    ListModel
    Enclosing class:
    TextListModelTag

    protected static class TextListModelTag.TextListModel
    extends Object
    implements ListModel
    A simple implementation of the ListModel interface that maintains a list of display texts and a list with the corresponding values. The value list can be null if no special values are needed.
    • Constructor Detail

      • TextListModel

        public TextListModel()
        Creates a new instance of TextListModel.
    • Method Detail

      • addItem

        public void addItem​(String display,
                            Object value)
        Adds a new item to this list model.
        Parameters:
        display - the display text
        value - the value of this item (can be null )
      • size

        public int size()
        Returns this model's size.
        Specified by:
        size in interface ListModel
        Returns:
        the size
      • getDisplayObject

        public Object getDisplayObject​(int index)
        Returns the display object with the given index.
        Specified by:
        getDisplayObject in interface ListModel
        Parameters:
        index - the index
        Returns:
        the display object with this index
      • getValueObject

        public Object getValueObject​(int index)
        Returns the value object with the given index.
        Specified by:
        getValueObject in interface ListModel
        Parameters:
        index - the index
        Returns:
        the value object with this index
      • getType

        public Class<?> getType()
        Returns the type of this model's value. If a type has explicitly been set, this type is returned. Otherwise the return value depends on the definition of value objects: if there are value objects, the type String is assumed, otherwise Integer.
        Specified by:
        getType in interface ListModel
        Returns:
        the type of the values
      • setType

        public void setType​(Class<?> type)
        Sets the type of the values of this list model.
        Parameters:
        type - the type