public class DefaultListModel<T> extends Object implements ListModel<T>
Constructor and Description |
---|
DefaultListModel()
Creates a new instance of DefaultListModel
|
DefaultListModel(Collection<T> items)
Creates a new instance of DefaultListModel
|
DefaultListModel(T[] items)
Creates a new instance of DefaultListModel
|
DefaultListModel(Vector<T> items)
Creates a new instance of DefaultListModel
|
Modifier and Type | Method and Description |
---|---|
void |
addDataChangedListener(DataChangedListener l)
Invoked to indicate interest in future change events
|
void |
addItem(T item)
Adds the specified item to the end of this list.
|
void |
addItemAtIndex(T item,
int index)
Adding an item to list at given index
|
void |
addSelectionListener(SelectionListener l)
Invoked to indicate interest in future selection events
|
protected void |
fireDataChangedEvent(int status,
int index)
Broadcast a change event to all listeners
|
T |
getItemAt(int index)
Returns the item at the given offset
|
List<T> |
getList()
Returns the internal list of items which makes traversal using iterators easier.
|
int |
getSelectedIndex()
Returns the selected list offset
|
int |
getSize()
Returns the number of items in the list
|
void |
removeAll()
Removes all elements from the model
|
void |
removeDataChangedListener(DataChangedListener l)
Invoked to indicate no further interest in future change events
|
void |
removeItem(int index)
Removes the item at the specified position in this list.
|
void |
removeSelectionListener(SelectionListener l)
Invoked to indicate no further interest in future selection events
|
void |
setItem(int index,
T item)
Change the item at the given index
|
void |
setSelectedIndex(int index)
Sets the selected list offset can be set to -1 to clear selection
|
public DefaultListModel()
public DefaultListModel(Vector<T> items)
items
- the items in the modelpublic DefaultListModel(Collection<T> items)
items
- the items in the modelpublic DefaultListModel(T[] items)
items
- the items in the modelpublic T getItemAt(int index)
ListModel
public int getSize()
ListModel
public int getSelectedIndex()
ListModel
getSelectedIndex
in interface ListModel<T>
public void addItem(T item)
ListModel
public void setItem(int index, T item)
index
- the offset for the itemitem
- the value to setpublic void addItemAtIndex(T item, int index)
item
- - the item to addindex
- - the index position in the listpublic void removeItem(int index)
ListModel
removeItem
in interface ListModel<T>
index
- the index of the item to removedpublic void removeAll()
public void setSelectedIndex(int index)
ListModel
setSelectedIndex
in interface ListModel<T>
index
- an index into this listpublic void addDataChangedListener(DataChangedListener l)
ListModel
addDataChangedListener
in interface ListModel<T>
l
- a data changed listenerpublic void removeDataChangedListener(DataChangedListener l)
ListModel
removeDataChangedListener
in interface ListModel<T>
l
- a data changed listenerprotected void fireDataChangedEvent(int status, int index)
status
- the status of the eventindex
- the index changedpublic void addSelectionListener(SelectionListener l)
ListModel
addSelectionListener
in interface ListModel<T>
l
- a selection listenerpublic void removeSelectionListener(SelectionListener l)
ListModel
removeSelectionListener
in interface ListModel<T>
l
- a selection listener