public class ResourceListModel
extends java.lang.Object
implements javax.swing.ListModel, java.io.Serializable
ResourceList
object. Every item represents a
Resource
from the
list. You must explicitly call
load() to load the information from the resource
list.
Use this class if you want to customize the graphical user interface that presents a list. If you do not need to customize the interface, then use ResourceListPane instead.
Most errors are reported as ErrorEvents rather than throwing exceptions. Users should listen for ErrorEvents in order to diagnose and recover from error conditions.
ResourceListModel objects generate the following events:
The following example creates a list model filled with the contents of a user list from a system. It then presents the list in a JList object.
// Create the resource list. This example creates // a list of all users on the system. AS400 system = new AS400("MYSYSTEM", "MYUSERID", "MYPASSWORD"); RUserList userList = new RUserList(system);
// Create the ResourceListModel. ResourceListModel listModel = new ResourceListModel(userList);
// Create a JList using the ResourceListModel. JList list = new JList(listModel);
// Add the JList to a JFrame and show it. JFrame frame = new JFrame("My Window"); frame.getContentPane().add(new JScrollPane(list)); frame.pack(); frame.show();
// The JList will appear empty until we tell the // ResourceListModel to load. This gives us control // of when the list of users is retrieved from the // system. listModel.load();
Constructor and Description |
---|
ResourceListModel()
Deprecated.
Constructs a ResourceListModel object.
|
ResourceListModel(ResourceList resourceList)
Deprecated.
Constructs a ResourceListModel object.
|
Modifier and Type | Method and Description |
---|---|
void |
addErrorListener(ErrorListener listener)
Deprecated.
Adds a listener to be notified when an error occurs.
|
void |
addListDataListener(javax.swing.event.ListDataListener listener)
Deprecated.
Adds a listener to be notified when the contents of
the list change.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated.
Adds a listener to be notified when the value of any
bound property changes.
|
void |
addWorkingListener(WorkingListener listener)
Deprecated.
Adds a listener to be notified when work starts and stops
on potentially long-running operations.
|
java.lang.Object |
getElementAt(int rowIndex)
Deprecated.
Returns the element at the specified index.
|
ResourceList |
getResourceList()
Deprecated.
Returns the resource list from which all information for the model is gathered.
|
int |
getSize()
Deprecated.
Returns the number of objects in the list.
|
void |
load()
Deprecated.
Loads the information from the resource list.
|
void |
removeErrorListener(ErrorListener listener)
Deprecated.
Removes an error listener.
|
void |
removeListDataListener(javax.swing.event.ListDataListener listener)
Deprecated.
Removes a list data listener.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated.
Removes a property change listener.
|
void |
removeWorkingListener(WorkingListener listener)
Deprecated.
Removes a working listener.
|
void |
setResourceList(ResourceList resourceList)
Deprecated.
Sets the resource list from which all information for the model is gathered.
|
public ResourceListModel()
public ResourceListModel(ResourceList resourceList)
resourceList
- The resource list.public void addErrorListener(ErrorListener listener)
listener
- The listener.public void addListDataListener(javax.swing.event.ListDataListener listener)
addListDataListener
in interface javax.swing.ListModel
listener
- The listener.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener.public void addWorkingListener(WorkingListener listener)
listener
- The listener.public java.lang.Object getElementAt(int rowIndex)
getElementAt
in interface javax.swing.ListModel
rowIndex
- The row index (0-based).public ResourceList getResourceList()
public int getSize()
getSize
in interface javax.swing.ListModel
public void load()
public void removeErrorListener(ErrorListener listener)
listener
- The listener.public void removeListDataListener(javax.swing.event.ListDataListener listener)
removeListDataListener
in interface javax.swing.ListModel
listener
- The listener.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener.public void removeWorkingListener(WorkingListener listener)
listener
- The listener.public void setResourceList(ResourceList resourceList)
resourceList
- The resource list from which all information for the model is gathered.