Class SingleListSelectionPolicy<V>

  • Type Parameters:
    V - The type of values contained in the select model.
    All Implemented Interfaces:
    ListSelectionPolicy<V>

    public final class SingleListSelectionPolicy<V>
    extends AbstractListSelectionPolicy<V>
    An implementation of a selection strategy for a select model allowing only a single selection at a time. This class is marked final because it demarcates certain selection semantics that, if they can be assumed, may be offloaded to a component's view in certain circumstances. This class is thread-safe, and assumes that the corresponding select model is thread-safe, synchronized on itself.
    Author:
    Garret Wilson
    See Also:
    ListSelectModel
    • Constructor Detail

      • SingleListSelectionPolicy

        public SingleListSelectionPolicy()
    • Method Detail

      • getSetSelectedIndices

        public int[] getSetSelectedIndices​(ListSelectModel<V> selectModel,
                                           int[] indices)
        Determines which requested indices may be set as the selection. This implementation allows the setting of all requested indices.

        This implementation allows the setting of all requested indices.

        This implementation only allows the first index to be set.

        Specified by:
        getSetSelectedIndices in interface ListSelectionPolicy<V>
        Overrides:
        getSetSelectedIndices in class AbstractListSelectionPolicy<V>
        Parameters:
        selectModel - The model containing the values to be selected.
        indices - The requested indices to set as the selection.
        Returns:
        The indices that can be set as the selection.
      • getAddSelectedIndices

        public int[] getAddSelectedIndices​(ListSelectModel<V> selectModel,
                                           int[] indices)
        Determines which requested indices may be added to the selection. This implementation allows the addition of all requested indices.

        This implementation allows the addition of all requested indices.

        This implementation allows the addition of all requested indices.

        Specified by:
        getAddSelectedIndices in interface ListSelectionPolicy<V>
        Overrides:
        getAddSelectedIndices in class AbstractListSelectionPolicy<V>
        Parameters:
        selectModel - The model containing the values to be selected.
        indices - The requested indices to add to the selection.
        Returns:
        The indices that can be added to the selection.