Class TrackListModel

java.lang.Object
  extended byTrackListModel
All Implemented Interfaces:
javax.swing.ComboBoxModel, javax.swing.ListModel

public class TrackListModel
extends java.lang.Object
implements javax.swing.ComboBoxModel

TrackListModel is a model for JComboBox. It implements the ComboBoxModel interface. This model contains a list of the names of the tracks available. Track names are all given at the same time with the setElements(String [] trks) method. The selected track can be queried with the Object getSelectedItem() method, which always returns a String object.

Version:
1.0
Author:
Stefan Brockmann, Tero Kuusela
See Also:
Tracksail

Field Summary
private  java.lang.String[] elements
          list elements (track names)
private  java.util.ArrayList listeners
          list of registered list data listeners
private  java.lang.Object selected
          the track that's selected in the ComboBox
 
Constructor Summary
TrackListModel()
           
 
Method Summary
 void addListDataListener(javax.swing.event.ListDataListener l)
          Adds a list data listener.
 java.lang.Object getElementAt(int index)
          Returns the name of the track with the given index.
 java.lang.Object getSelectedItem()
          Returns the name of the selected track.
 int getSize()
          Returns the number of the tracks in this list.
 void removeListDataListener(javax.swing.event.ListDataListener l)
          Removes a list data listener.
 void setElements(java.lang.String[] trks)
          Sets the content of the model (track names).
 void setSelectedItem(java.lang.Object item)
          Sets the selected track.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

private java.util.ArrayList listeners
list of registered list data listeners


elements

private java.lang.String[] elements
list elements (track names)


selected

private java.lang.Object selected
the track that's selected in the ComboBox

Constructor Detail

TrackListModel

public TrackListModel()
Method Detail

addListDataListener

public void addListDataListener(javax.swing.event.ListDataListener l)
Adds a list data listener.

Specified by:
addListDataListener in interface javax.swing.ListModel
Parameters:
l - ListDataListener object

removeListDataListener

public void removeListDataListener(javax.swing.event.ListDataListener l)
Removes a list data listener.

Specified by:
removeListDataListener in interface javax.swing.ListModel
Parameters:
l - ListDataListener object

getElementAt

public java.lang.Object getElementAt(int index)
Returns the name of the track with the given index.

Specified by:
getElementAt in interface javax.swing.ListModel
Parameters:
index - index of the track to return the name of
Returns:
Name of the track with the given index.

getSize

public int getSize()
Returns the number of the tracks in this list.

Specified by:
getSize in interface javax.swing.ListModel
Returns:
Number of tracks in this list.

setElements

public void setElements(java.lang.String[] trks)
Sets the content of the model (track names).

Everything is done directly with one array.

Parameters:
trks - tracks as a String array

getSelectedItem

public java.lang.Object getSelectedItem()
Returns the name of the selected track.

Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel
Returns:
Name of the selected track.

setSelectedItem

public void setSelectedItem(java.lang.Object item)
Sets the selected track.

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
Parameters:
item - Name of the selected track.