|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
javax.swing.AbstractListModel
oracle.javatools.controls.SimpleListModel<T>
public class SimpleListModel<T>
A simple list model based on a delegate java.util.List. The model contains utility methods for moving single elements up and down in the list and adding / removing elements firing the necessary events.
Also very useful is the removeIndices(int[]) method. This is a highly optimized way to remove a set of items from the model firing only the minimum necessary events for performance reasons. It's handy to use this if you have a JList which supports removal of a multiple selection.
The asList()
method returns an object that implements the List
interface. Changes you make to this list will automatically fire events to listeners of this list model. This is convenient if you want to pass a list model down to code that uses the collections framework.
Field Summary |
---|
Fields inherited from class javax.swing.AbstractListModel |
---|
listenerList |
Constructor Summary | |
---|---|
SimpleListModel() Create a simple list model based on a new ArrayList. |
|
SimpleListModel(java.util.List<T> list) Create a simple list model based on the specified delegate list. |
Method Summary | |
---|---|
void |
addElement(T o) Add an element, firing an intervalAdded event. |
void |
addElements(java.util.Iterator<T> i) Deprecated. use asList() .addAll( Collection ). |
java.util.List<T> |
asList() Returns a List implementation that is bound to this list model. |
void |
changed() Fire a contentsChanged event for the whole list. |
void |
changed(int index) Fire a contentsChanged event for the element at the specified index. |
T |
getElementAt(int i) Get an element in the model by its index. |
int |
getSize() Get the number of elements in the model. |
void |
insertAt(int index, T o) Insert the specified element at the specified index in the list. |
java.util.Iterator<T> |
iterator() Get an iterator over all items in the model. |
void |
moveDown(int index) Move the element at the specified index down one position, firing the necessary intervalRemoved and intervalAdded events. |
void |
moveUp(int index) Move the element at the specified index up one position, firing the necessary intervalRemoved and intervalAdded events. |
void |
removeAll() Remove all elements in the list, firing an intervalRemoved event. |
void |
removeElement(T o) Remove a single element, firing an intervalRemoved event. |
void |
removeIndices(int[] indices) Remove the specified indices from the model efficiently. |
Methods inherited from class javax.swing.AbstractListModel |
---|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleListModel()
public SimpleListModel(java.util.List<T> list)
list
- the delegate list to base the model on.java.lang.NullPointerException
- if list is null.Method Detail |
---|
public java.util.List<T> asList()
List
implementation that is bound to this list model.
The binding behavior means that you can safely call methods on the returned List that make changes to the list, and they will be reflected in the model, firing appropriate events.
public int getSize()
getSize
in interface javax.swing.ListModel
public T getElementAt(int i)
getElementAt
in interface javax.swing.ListModel
i
- the index of an element in the model. Must be >= 0 and < this.getSize()
.java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).public java.util.Iterator<T> iterator()
Iterator.remove()
will result in an UnsupportedOperationException. For a modifiable iterator, use asList()
.iterator().iterator
in interface java.lang.Iterable<T>
public void addElements(java.util.Iterator<T> i)
asList()
.addAll( Collection ).i
- the iterator over elements to add to the list.java.lang.NullPointerException
- if i is null.public void addElement(T o)
o
- the element to add.public void removeIndices(int[] indices)
model.removeIndices( list.getSelectedIndices() );
indices
- the indices to remove. The indices must be sorted. i.e. for all x : indices[x] < indices[x+1].java.lang.NullPointerException
- if indices is null.public void removeElement(T o)
o
- the element to remove.public void removeAll()
public void changed(int index)
index
- the index of an element that has changed. Must be >=0 and <getSize().java.lang.IndexOutOfBoundsException
- if index is out of bounds.public void changed()
public void moveUp(int index)
index
- the index of an element to move up. Must be >=0 and <getSize(). If index is 0, this method does nothing.java.lang.IndexOutOfBoundsException
- if index is out of bounds.public void moveDown(int index)
index
- the index of an element to move down. Must be >=0 and <getSize(). If index is getSize()-1, this method does nothing.java.lang.IndexOutOfBoundsException
- if index is out of bounds.public void insertAt(int index, T o)
index
- the index to insert at.o
- the object to insert.
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |