
import java.util.List;
import java.util.LinkedList;
import javax.swing.*;

/**
 * Created by IntelliJ IDEA.
 *
 * @author armond
 *         Date: Mar 12, 2005
 */
public class DynamicComboBoxModel extends AbstractListModel implements ComboBoxModel
{
	protected List model = new LinkedList();
	protected Object selectedObject = null;

	public int getSize()
	{
		return model.size();
	}

	public Object getElementAt(int index)
	{
		return model.get(index);
	}

	public Object getSelectedItem()
	{
		return selectedObject;
	}

	public void setSelectedItem(Object anObject)
	{
		if ((selectedObject != null && !selectedObject.equals( anObject )) ||
			selectedObject == null && anObject != null)
		{
			selectedObject = anObject;
			fireContentsChanged(this, -1, -1);
		}
	}
}
