001package jmri.swing;
002
003import java.awt.Component;
004import javax.swing.DefaultCellEditor;
005import javax.swing.JCheckBox;
006import javax.swing.JComboBox;
007import javax.swing.JList;
008import javax.swing.JTextField;
009
010/**
011 *
012 * @author Randall Wood
013 */
014public class DefaultListCellEditor<E> extends DefaultCellEditor implements ListCellEditor<E> {
015
016    public DefaultListCellEditor(final JCheckBox checkBox) {
017        super(checkBox);
018    }
019
020    public DefaultListCellEditor(final JComboBox<?> comboBox) {
021        super(comboBox);
022    }
023
024    public DefaultListCellEditor(final JTextField textField) {
025        super(textField);
026    }
027
028    @Override
029    public Component getListCellEditorComponent(JList<E> list, E value, boolean isSelected, int index) {
030        delegate.setValue(value);
031        return editorComponent;
032    }
033
034    @Override
035    @SuppressWarnings("unchecked") // made safe by construction
036    public E getCellEditorValue() {
037        return (E) super.getCellEditorValue();
038    }
039
040}