lapisx.swing
Class HistoryComboBoxModel

java.lang.Object
  extended bylapisx.util.History
      extended bylapisx.swing.HistoryComboBoxModel
All Implemented Interfaces:
ComboBoxModel, ListModel

public class HistoryComboBoxModel
extends History
implements ComboBoxModel

An adapter for lapisx.util.History that allows a history to be used as the model for a JComboBox.

Example of use:

 // make a history with room for 10 elements
 HistoryComboBoxModel history = new HistoryComboBoxModel (10);
 // make a combo box that displays the history in its drop-down list
 JComboBox combobox = new JComboBox (history);
 


Field Summary
protected  EventListenerList listenerList
          Listeners on this object.
 
Fields inherited from class lapisx.util.History
curr, end, history, start
 
Constructor Summary
HistoryComboBoxModel(History h)
          Make a duplicate of another History.
HistoryComboBoxModel(int max)
          Make a HistoryComboBoxModel.
 
Method Summary
 void addListDataListener(ListDataListener l)
           
protected  void fire(int eventType, int start, int end)
           
protected  void fireAdded(int i, int j)
          Called when new elements are added at history[i..j].
protected  void fireChanged(int i, int j)
          Called when elements at history[i..j] are replaced.
protected  void fireRemoved(int i, int j)
          Called when history[i..j] is removed.
 Object getElementAt(int index)
           
 Object getSelectedItem()
           
 int getSize()
           
 void removeListDataListener(ListDataListener l)
           
 void setSelectedItem(Object obj)
           
 
Methods inherited from class lapisx.util.History
add, back, backElements, canBack, canForward, clear, contains, elements, expand, forward, forwardElements, get, isEmpty, isFull, jumpTo, peekBack, peekForward, put, replace, size, toEnd, toStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

protected EventListenerList listenerList
Listeners on this object.

Constructor Detail

HistoryComboBoxModel

public HistoryComboBoxModel(int max)
Make a HistoryComboBoxModel.

Parameters:
max - Maximum length of history

HistoryComboBoxModel

public HistoryComboBoxModel(History h)
Make a duplicate of another History.

Parameters:
h - History to copy
Method Detail

addListDataListener

public void addListDataListener(ListDataListener l)
Specified by:
addListDataListener in interface ListModel

removeListDataListener

public void removeListDataListener(ListDataListener l)
Specified by:
removeListDataListener in interface ListModel

getSize

public int getSize()
Specified by:
getSize in interface ListModel

getElementAt

public Object getElementAt(int index)
Specified by:
getElementAt in interface ListModel

getSelectedItem

public Object getSelectedItem()
Specified by:
getSelectedItem in interface ComboBoxModel

setSelectedItem

public void setSelectedItem(Object obj)
Specified by:
setSelectedItem in interface ComboBoxModel

fireRemoved

protected void fireRemoved(int i,
                           int j)
Description copied from class: History
Called when history[i..j] is removed. Used by subclasses that need to generate events. Default implementation does nothing.

Overrides:
fireRemoved in class History
Parameters:
i - index of first removed element
j - index of last removed element

fireAdded

protected void fireAdded(int i,
                         int j)
Description copied from class: History
Called when new elements are added at history[i..j]. Used by subclasses that need to generate events. Default implementation does nothing.

Overrides:
fireAdded in class History
Parameters:
i - index of first added element
j - index of last added element

fireChanged

protected void fireChanged(int i,
                           int j)
Description copied from class: History
Called when elements at history[i..j] are replaced. Also called when history[i] becomes the current element (in which case i == j). Used by subclasses that need to generate events. Default implementation does nothing.

Overrides:
fireChanged in class History
Parameters:
i - index of first changed element
j - index of last changed element

fire

protected void fire(int eventType,
                    int start,
                    int end)