public class ListModelSet<E> extends AbstractListModel<E> implements Sortable<E>, java.util.Set<E>, java.io.Serializable
This is the ListModel
as a Set
to be used with Listbox
.
Add or remove the contents of this model as a Set would cause the associated Listbox to change accordingly.
ListModel
,
ListModelList
,
ListModelMap
,
Serialized FormAbstractListModel.DefaultSelectionControl<E>
Modifier and Type | Field and Description |
---|---|
protected java.util.Set<E> |
_set |
_selection
INTERNAL_EVENT
Constructor and Description |
---|
ListModelSet()
Constructor.
|
ListModelSet(java.util.Collection<? extends E> c)
Constructor.
|
ListModelSet(E[] array)
Constructor.
|
ListModelSet(int initialCapacity)
Constructor.
|
ListModelSet(int initialCapacity,
float loadFactor)
Constructor.
|
ListModelSet(java.util.Set<E> set,
boolean live)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o)
This implementation optimized on the LinkedHashSet(which guarantees the sequence of the added item).
|
boolean |
addAll(java.util.Collection<? extends E> c)
This implementation optimized on the LinkedHashSet(which
guarantees the sequence of the added item).
|
void |
addSelection(E obj)
Deprecated.
As of release 6.0.0, replaced with
AbstractListModel.addToSelection(E) . |
void |
clear() |
java.lang.Object |
clone() |
boolean |
contains(java.lang.Object elem) |
boolean |
containsAll(java.util.Collection<?> c) |
boolean |
equals(java.lang.Object o) |
protected void |
fireSelectionEvent(E e)
Selectable's implementor use only.
|
E |
getElementAt(int j)
Returns the value at the specified index.
|
java.util.Set<E> |
getInnerSet()
Get the inner real set.
|
int |
getSize()
Returns the length of the list.
|
java.lang.String |
getSortDirection(java.util.Comparator<E> cmpr)
Returns the sort direction of this model for the given comparator.
|
int |
hashCode() |
int |
indexOf(java.lang.Object o)
Returns the index of the specified object, or -1 if not found.
|
boolean |
isEmpty() |
java.util.Iterator<E> |
iterator() |
boolean |
notifyChange(E element)
Notifies a change of the same element to trigger an event of
ListDataEvent.CONTENTS_CHANGED . |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
void |
removeSelection(java.lang.Object obj)
Deprecated.
As of release 6.0.0, replaced with
AbstractListModel.removeFromSelection(java.lang.Object) . |
boolean |
retainAll(java.util.Collection<?> c) |
int |
size() |
void |
sort(java.util.Comparator<E> cmpr,
boolean ascending)
Sorts the data.
|
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
java.lang.String |
toString() |
addListDataListener, addPagingEventListener, addToSelection, clearSelection, fireEvent, getActivePage, getPageCount, getPageSize, getSelection, getSelectionControl, isMultiple, isSelected, isSelectionEmpty, newEmptySelection, readSelection, removeAllSelection, removeFromSelection, removeListDataListener, removePagingEventListener, retainAllSelection, setActivePage, setMultiple, setPageSize, setSelection, setSelectionControl, writeSelection
protected java.util.Set<E> _set
public ListModelSet(java.util.Set<E> set, boolean live)
set
- the set to representlive
- whether to have a 'live' ListModel
on top of
the specified set.
If false, the content of the specified set is copied.
If true, this object is a 'facade' of the specified set,
i.e., when you add or remove items from this ListModelSet
,
the inner "live" set would be changed accordingly.
However, it is not a good idea to modify set
if it is passed to this method with live is true,
since Listbox
is not smart enough to handle it.
Instead, modify it thru this object.public ListModelSet()
public ListModelSet(java.util.Collection<? extends E> c)
Notice that if the data is static or not shared, it is better to
use ListModelSet(set, true)
instead, since
making a copy is slower.
public ListModelSet(E[] array)
public ListModelSet(int initialCapacity)
initialCapacity
- the initial capacity for this ListModelSet.public ListModelSet(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacity for this ListModelMap.loadFactor
- the loadFactor to increase capacity of this ListModelMap.public java.util.Set<E> getInnerSet()
public int getSize()
ListModel
public E getElementAt(int j)
ListModel
getElementAt
in interface ListModel<E>
public boolean notifyChange(E element)
ListDataEvent.CONTENTS_CHANGED
.element
- public boolean add(E o)
public boolean addAll(java.util.Collection<? extends E> c)
public void clear()
public boolean contains(java.lang.Object elem)
public boolean containsAll(java.util.Collection<?> c)
public boolean equals(java.lang.Object o)
public int hashCode()
public boolean isEmpty()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Iterator<E> iterator()
public boolean remove(java.lang.Object o)
public int indexOf(java.lang.Object o)
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public int size()
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
public void sort(java.util.Comparator<E> cmpr, boolean ascending)
public java.lang.String getSortDirection(java.util.Comparator<E> cmpr)
Sortable
Default: "natural".
getSortDirection
in interface Sortable<E>
public java.lang.Object clone()
clone
in class AbstractListModel<E>
protected void fireSelectionEvent(E e)
AbstractListModel
Fires a selection event for component to scroll into view. The override
subclass must put the index0 of AbstractListModel.fireEvent(int, int, int)
as
the view index to scroll. By default, the value -1 is assumed which means
no scroll into view.
The method is invoked when both methods are invoked. AbstractListModel.addToSelection(Object)
and AbstractListModel.setSelection(Collection)
.
fireSelectionEvent
in class AbstractListModel<E>
e
- selected object.public void addSelection(E obj)
AbstractListModel.addToSelection(E)
.public void removeSelection(java.lang.Object obj)
AbstractListModel.removeFromSelection(java.lang.Object)
.Copyright © 2005-2018 Potix Corporation. All Rights Reserved.