public class DefaultListModel<T> extends AbstractListModel<T>
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
editable |
protected List<T> |
elements |
protected ListSelectionModel |
movableElements |
protected ListSelectionModel |
removableElements |
listEditorDataListeners| Constructor and Description |
|---|
DefaultListModel() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
T element) |
void |
add(int index,
T element,
boolean removable,
boolean movable) |
void |
add(T element)
Adds
element to the list and marks it as not removable and not movable. |
void |
add(T element,
boolean removable,
boolean movable)
Adds
element to the list. |
void |
addAll(Collection<T> elements)
Same as calling
addAll(elements, false, false). |
void |
addAll(Collection<T> elements,
boolean removable,
boolean movable)
Appends all of the elements in
elements to the end of this list. |
void |
clear() |
void |
clearAndAddAll(Collection<? extends T> elements,
boolean removable,
boolean movable)
Clears all the elements of the current list, then adds the elements of
elements and finally fires a
ListDataEvent.CONTENTS_CHANGED event i.e. |
void |
clearAndAddAll(Collection<? extends T> elements,
boolean removable,
boolean movable,
boolean fireEvent)
Clears all the elements of the current list, then adds the elements of
elements and, if fireEvent is
true, finally fires a ListDataEvent.CONTENTS_CHANGED event i.e. |
void |
clearAndAddAll(Collection<T> elements)
|
T |
elementAt(int index)
Returns the element at position
index. |
List<T> |
getElements()
Returns all elements.
|
boolean |
isEditable()
Returns whether this list is marked as _editable_ or not.
|
boolean |
isEmpty() |
boolean |
isMovable(int index)
Returns whether the element at position
index is movable or not. |
boolean |
isRemovable(int index)
Returns whether the element at position
index is removable or not. |
void |
moveElement(int fromIndex,
int toIndex)
Moves an element from position
fromIndex to position toIndex. |
T |
remove(int index) |
boolean |
remove(T element) |
void |
removeAll(Collection<T> elements) |
void |
removeRange(int fromIndex,
int toIndex)
Removes elements in the range [
fromIndex toIndex]. |
void |
set(int index,
T element) |
T |
set(int index,
T element,
boolean removable,
boolean movable) |
void |
setEditable(boolean editable) |
void |
setMovable(int index,
boolean movable) |
void |
setMovableElementsModel(ListSelectionModel model) |
void |
setRemovable(int index,
boolean removable) |
void |
setRemovableElementsModel(ListSelectionModel model) |
int |
size()
Returns the size of this list i.e.
|
String |
toString() |
addListModelDataListener, fireEvent, getListDataListeners, removeListModelDataListenerprotected ListSelectionModel movableElements
protected ListSelectionModel removableElements
protected boolean editable
public void add(T element)
element to the list and marks it as not removable and not movable. Same as calling
add(element, false, false).element - the element to be addedadd(Object, boolean, boolean)public void add(T element, boolean removable, boolean movable)
element to the list.element - the element to be addedremovable - whether element should be marked as removable or notmovable - whether element should be marked as movable or notpublic void add(int index,
T element)
throws IndexOutOfBoundsException
IndexOutOfBoundsExceptionpublic void add(int index,
T element,
boolean removable,
boolean movable)
throws IndexOutOfBoundsException
IndexOutOfBoundsExceptionpublic void addAll(Collection<T> elements)
addAll(elements, false, false).elements - addAll(Collection, boolean, boolean)public void addAll(Collection<T> elements, boolean removable, boolean movable)
elements to the end of this list. Any registered
ListDataListeners will be notified that an interval has been added.elements - elements to be appendedremovable - whether the elements are removable or notmovable - whether the elements are movable or notpublic void clearAndAddAll(Collection<? extends T> elements, boolean removable, boolean movable)
elements and finally fires a
ListDataEvent.CONTENTS_CHANGED event i.e. no add and/or remove events are sent. clearAndAddAll(elements, false, false, true).elements - the elements to addremovable - whether the elements are removable or notmovable - whether the elements are movable or notclearAndAddAll(Collection)public void clearAndAddAll(Collection<? extends T> elements, boolean removable, boolean movable, boolean fireEvent)
elements and, if fireEvent is
true, finally fires a ListDataEvent.CONTENTS_CHANGED event i.e. no add and/or remove events are sent.elements - the elements to addremovable - whether the elements are removable or notmovable - whether the elements are movable or notfireEvent - whether an event should be fired or notclearAndAddAll(Collection)public void clearAndAddAll(Collection<T> elements)
elements - the elements to addclearAndAddAll(Collection, boolean, boolean)public void set(int index,
T element)
throws IndexOutOfBoundsException
IndexOutOfBoundsExceptionpublic void removeRange(int fromIndex,
int toIndex)
throws ArrayIndexOutOfBoundsException,
IllegalArgumentException
fromIndex toIndex].fromIndex - (inclusive) index of the first element in the rangetoIndex - (inclusive) index of the last element in the rangeArrayIndexOutOfBoundsException - if either fromIndex or toIndex is invalidIllegalArgumentException - if fromIndex is greater than toIndexpublic T remove(int index) throws IndexOutOfBoundsException
IndexOutOfBoundsExceptionpublic boolean remove(T element)
public void removeAll(Collection<T> elements)
public void clear()
clearAndAddAll(Collection)public T elementAt(int index) throws IndexOutOfBoundsException
ListModelindex.index - position of the element to getindexIndexOutOfBoundsException - if there is no element at position indexpublic List<T> getElements()
ListModelpublic int size()
ListModelpublic void setEditable(boolean editable)
public boolean isEditable()
ListModeltrue if this list is marked as editable, false otherwisepublic void setMovable(int index,
boolean movable)
public boolean isMovable(int index)
throws IndexOutOfBoundsException
ListModelindex is movable or not.index - position of the elementtrue if the element is movable, false otherwiseIndexOutOfBoundsException - if there is no element at position indexpublic void setRemovable(int index,
boolean removable)
public boolean isRemovable(int index)
throws IndexOutOfBoundsException
ListModelindex is removable or not.index - position of the elementtrue if the element is removable, false otherwiseIndexOutOfBoundsException - if there is no element at position indexpublic void setMovableElementsModel(ListSelectionModel model)
public void setRemovableElementsModel(ListSelectionModel model)
public void moveElement(int fromIndex,
int toIndex)
fromIndex to position toIndex. Implicitly fires event
since it calls add(int, Object, boolean, boolean) and remove(int)fromIndex - the current position index of the item to movetoIndex - the new position index of the itemadd(int, Object, boolean, boolean),
remove(int)public boolean isEmpty()
Copyright © 2017 SAP SE. All Rights Reserved.