FileDocCategorySizeDatePackage
ListComboBoxModel.javaAPI DocExample1856Mon Jan 09 11:01:58 GMT 2006None

ListComboBoxModel

public class ListComboBoxModel extends Object implements ActionListener, ComboBoxModel

Fields Summary
protected List
data
protected Object
selected
protected List
listeners
Constructors Summary
ListComboBoxModel()

        this.listeners = new ArrayList();
        data = new ArrayList();
    
public ListComboBoxModel(List list)

        this();
        this.data = list;
        if(list.size() > 0) {
            selected = list.get(0);
        }
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent evt)

        if(evt.getActionCommand().equals("update")) {
            this.fireUpdate();
        }
    
public voidaddListDataListener(javax.swing.event.ListDataListener l)

        listeners.add(l);
    
public voidfireUpdate()

        ListDataEvent le = new ListDataEvent(this, 
            ListDataEvent.CONTENTS_CHANGED,
            0,
            data.size());
        for(int i=0; i<listeners.size(); i++) {
            ListDataListener l = (ListDataListener)listeners.get(i);
            l.contentsChanged(le);
        }
    
public java.lang.ObjectgetElementAt(int index)

        return data.get(index);
    
public java.lang.ObjectgetSelectedItem()

        return this.selected;
    
public intgetSize()

        return data.size();
    
public voidremoveListDataListener(javax.swing.event.ListDataListener l)

        this.listeners.remove(l);
    
public voidsetSelectedItem(java.lang.Object item)

        this.selected = item;