|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractListModel
gov.nasa.gsfc.drl.rtstps.library.AListModel
public class AListModel
This class implements a list model to be used by JList and JComboBox. It also possesses features so that it can be used by AComboModel.
AListModel combines a java.util.List with an AbstractListModel so that you can use it as a java List and also plug it into a JList. AbstractListModel does not give you these features. This is not an abstract class, so you can use it to create a model.
You can add, change, or remove items in the list through AListModel, or you can change the list directly. However, if you modify the list outside of AListModel, you must call AListModel's fireContentsChanged method afterwards to force the graphics component (JList or JComboBox) to update its view.
The model has property change methods that tell listeners if the model has switched from empty to non-empty or non-empty to empty state. Although not directly used by JList or JComboBox, other listeners can use the property to enable or disable a JList or JComboBox depending on available list data. Attach a property change listener and wait for the "empty" property to change to true or false.
Field Summary | |
---|---|
protected java.util.List<java.lang.String> |
data
|
private javax.swing.event.SwingPropertyChangeSupport |
propSupport
|
private static long |
serialVersionUID
|
Fields inherited from class javax.swing.AbstractListModel |
---|
listenerList |
Constructor Summary | |
---|---|
AListModel()
An empty constructor. |
|
AListModel(java.util.Collection<java.lang.String> c)
This AListModel constructor creates a model constructed from the passed collection. |
|
AListModel(int initialCapacity)
Construct an AListModel. |
|
AListModel(java.util.List<java.lang.String> list)
Construct an AListModel using the passed list as a container. |
Method Summary | |
---|---|
void |
add(int index,
java.lang.String obj)
Add an object to the model but only if it is not a duplicate (via isEquals). |
void |
add(java.lang.String obj)
Append an object to the model but only if it is not a duplicate (via isEquals). |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener to listen for the "empty" property. |
void |
clear()
Remove all elements from the model. |
boolean |
contains(java.lang.Object obj)
Determine if the model contains the object via the equals method. |
java.lang.Object |
find(java.lang.Object obj)
Find an object in the model via the equals method. |
void |
fireContentsChanged()
Notify the model that the contents have changed. |
java.lang.Object |
get(int index)
Get the element at index index . |
java.lang.Object |
getElementAt(int index)
Get the element at index index . |
int |
getSize()
Get the current number of elements in the model. |
int |
indexOf(java.lang.Object obj)
Get the array index of an object. |
boolean |
isEmpty()
Determine if the model has no elements. |
void |
remove(int index)
Remove an object from the model. |
void |
remove(java.lang.Object obj)
Remove an object from the model. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener to listen for the "empty" property. |
void |
setData(java.util.List<java.lang.String> list)
Change the underlying collection to a different list. |
void |
sort()
Sort the objects in natural order. |
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 |
Field Detail |
---|
protected java.util.List<java.lang.String> data
private javax.swing.event.SwingPropertyChangeSupport propSupport
private static final long serialVersionUID
Constructor Detail |
---|
public AListModel()
public AListModel(int initialCapacity)
initialCapacity
- The initial list capacity.public AListModel(java.util.Collection<java.lang.String> c)
public AListModel(java.util.List<java.lang.String> list)
Method Detail |
---|
public int getSize()
public void setData(java.util.List<java.lang.String> list)
public void clear()
public java.lang.Object getElementAt(int index)
index
. This method satisfies
the ListModel interface. It is the same as get(int)
.
public java.lang.Object get(int index)
index
.
public void fireContentsChanged()
public boolean isEmpty()
public int indexOf(java.lang.Object obj)
public boolean contains(java.lang.Object obj)
public java.lang.Object find(java.lang.Object obj)
public void sort()
Comparable
public void add(java.lang.String obj)
public void add(int index, java.lang.String obj)
index
- The object is placed at this index location.public void remove(int index)
index
- Remove the object at the index location.public void remove(java.lang.Object obj)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |