javax.swing
Interface ListModel

All Known Subinterfaces:
ComboBoxModel sample code for javax.swing.ComboBoxModel definition code for javax.swing.ComboBoxModel , MutableComboBoxModel sample code for javax.swing.MutableComboBoxModel definition code for javax.swing.MutableComboBoxModel
All Known Implementing Classes:
AbstractListModel sample code for javax.swing.AbstractListModel definition code for javax.swing.AbstractListModel , BasicDirectoryModel sample code for javax.swing.plaf.basic.BasicDirectoryModel definition code for javax.swing.plaf.basic.BasicDirectoryModel , DefaultComboBoxModel sample code for javax.swing.DefaultComboBoxModel definition code for javax.swing.DefaultComboBoxModel , DefaultListModel sample code for javax.swing.DefaultListModel definition code for javax.swing.DefaultListModel , MetalFileChooserUI.DirectoryComboBoxModel sample code for javax.swing.plaf.metal.MetalFileChooserUI.DirectoryComboBoxModel definition code for javax.swing.plaf.metal.MetalFileChooserUI.DirectoryComboBoxModel , MetalFileChooserUI.FilterComboBoxModel sample code for javax.swing.plaf.metal.MetalFileChooserUI.FilterComboBoxModel definition code for javax.swing.plaf.metal.MetalFileChooserUI.FilterComboBoxModel

public interface ListModel

This interface defines the methods components like JList use to get the value of each cell in a list and the length of the list. Logically the model is a vector, indices vary from 0 to ListDataModel.getSize() - 1. Any change to the contents or length of the data model must be reported to all of the ListDataListeners.

See Also:
JList sample code for javax.swing.JList definition code for javax.swing.JList

Method Summary
 void addListDataListener sample code for javax.swing.ListModel.addListDataListener(javax.swing.event.ListDataListener) definition code for javax.swing.ListModel.addListDataListener(javax.swing.event.ListDataListener) (ListDataListener sample code for javax.swing.event.ListDataListener definition code for javax.swing.event.ListDataListener  l)
          Adds a listener to the list that's notified each time a change to the data model occurs.
 Object sample code for java.lang.Object definition code for java.lang.Object getElementAt sample code for javax.swing.ListModel.getElementAt(int) definition code for javax.swing.ListModel.getElementAt(int) (int index)
          Returns the value at the specified index.
 int getSize sample code for javax.swing.ListModel.getSize() definition code for javax.swing.ListModel.getSize() ()
          Returns the length of the list.
 void removeListDataListener sample code for javax.swing.ListModel.removeListDataListener(javax.swing.event.ListDataListener) definition code for javax.swing.ListModel.removeListDataListener(javax.swing.event.ListDataListener) (ListDataListener sample code for javax.swing.event.ListDataListener definition code for javax.swing.event.ListDataListener  l)
          Removes a listener from the list that's notified each time a change to the data model occurs.
 

Method Detail

getSize sample code for javax.swing.ListModel.getSize() definition code for javax.swing.ListModel.getSize()

int getSize()
Returns the length of the list.

Returns:
the length of the list

getElementAt sample code for javax.swing.ListModel.getElementAt(int) definition code for javax.swing.ListModel.getElementAt(int)

Object sample code for java.lang.Object definition code for java.lang.Object  getElementAt(int index)
Returns the value at the specified index.

Parameters:
index - the requested index
Returns:
the value at index

addListDataListener sample code for javax.swing.ListModel.addListDataListener(javax.swing.event.ListDataListener) definition code for javax.swing.ListModel.addListDataListener(javax.swing.event.ListDataListener)

void addListDataListener(ListDataListener sample code for javax.swing.event.ListDataListener definition code for javax.swing.event.ListDataListener  l)
Adds a listener to the list that's notified each time a change to the data model occurs.

Parameters:
l - the ListDataListener to be added

removeListDataListener sample code for javax.swing.ListModel.removeListDataListener(javax.swing.event.ListDataListener) definition code for javax.swing.ListModel.removeListDataListener(javax.swing.event.ListDataListener)

void removeListDataListener(ListDataListener sample code for javax.swing.event.ListDataListener definition code for javax.swing.event.ListDataListener  l)
Removes a listener from the list that's notified each time a change to the data model occurs.

Parameters:
l - the ListDataListener to be removed