public ListEditor(Vector<String> model){
  this.listeners=new Vector<ListDataListener>();
  setLayout(new GridBagLayout());
  editor=new LimeTextField("");
  editor.setColumns(DEFAULT_COLUMNS);
  editor.setPreferredSize(new Dimension(500,20));
  editor.setMaximumSize(new Dimension(500,20));
  GridBagConstraints gbc=new GridBagConstraints();
  gbc.fill=GridBagConstraints.BOTH;
  gbc.anchor=GridBagConstraints.NORTHWEST;
  gbc.weightx=1;
  add(editor,gbc);
  Action addAction=new AddAction();
  addButton=new JButton(addAction);
  GUIUtils.bindKeyToAction(editor,KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0),addAction);
  gbc=new GridBagConstraints();
  gbc.anchor=GridBagConstraints.NORTHWEST;
  gbc.insets=new Insets(0,ButtonRow.BUTTON_SEP,0,0);
  add(addButton,gbc);
  Action removeAction=new RemoveAction();
  removeButton=new JButton(removeAction);
  removeButton.setEnabled(false);
  gbc.gridwidth=GridBagConstraints.REMAINDER;
  add(removeButton,gbc);
  list=new JList<Object>();
  list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  list.addListSelectionListener(new ListListener());
  GUIUtils.bindKeyToAction(list,KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0),removeAction);
  JScrollPane scrollPane=new JScrollPane(list,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  setModel(model);
  scrollPane.setPreferredSize(new Dimension(500,50));
  scrollPane.setMaximumSize(new Dimension(500,50));
  gbc=new GridBagConstraints();
  gbc.insets=new Insets(ButtonRow.BUTTON_SEP,0,0,0);
  gbc.gridwidth=GridBagConstraints.REMAINDER;
  gbc.anchor=GridBagConstraints.NORTHWEST;
  gbc.fill=GridBagConstraints.BOTH;
  gbc.weighty=1;
  add(scrollPane,gbc);
}

public ListEditor ( Vector < String > model ) { this . listeners = new Vector < ListDataListener > ( ) ; setLayout ( new GridBagLayout ( ) ) ; editor = new LimeTextField ( "" ) ; editor . setColumns ( DEFAULT_COLUMNS ) ; editor . setPreferredSize ( new Dimension ( 500 , 20 ) ) ; editor . setMaximumSize ( new Dimension ( 500 , 20 ) ) ; GridBagConstraints gbc = new GridBagConstraints ( ) ; gbc . fill = GridBagConstraints . BOTH ; gbc . anchor = GridBagConstraints . NORTHWEST ; gbc . weightx = 1 ; add ( editor , gbc ) ; Action addAction = new AddAction ( ) ; addButton = new JButton ( addAction ) ; GUIUtils . bindKeyToAction ( editor , KeyStroke . getKeyStroke ( KeyEvent . VK_ENTER , 0 ) , addAction ) ; gbc = new GridBagConstraints ( ) ; gbc . anchor = GridBagConstraints . NORTHWEST ; gbc . insets = new Insets ( 0 , ButtonRow . BUTTON_SEP , 0 , 0 ) ; add ( addButton , gbc ) ; Action removeAction = new RemoveAction ( ) ; removeButton = new JButton ( removeAction ) ; removeButton . setEnabled ( false ) ; gbc . gridwidth = GridBagConstraints . REMAINDER ; add ( removeButton , gbc ) ; list = new JList < Object > ( ) ; list . setSelectionMode ( ListSelectionModel . SINGLE_SELECTION ) ; list . addListSelectionListener ( new ListListener ( ) ) ; GUIUtils . bindKeyToAction ( list , KeyStroke . getKeyStroke ( KeyEvent . VK_DELETE , 0 ) , removeAction ) ; JScrollPane scrollPane = new JScrollPane ( list , JScrollPane . VERTICAL_SCROLLBAR_ALWAYS , JScrollPane . HORIZONTAL_SCROLLBAR_AS_NEEDED ) ; setModel ( model ) ; scrollPane . setPreferredSize ( new Dimension ( 500 , 50 ) ) ; scrollPane . setMaximumSize ( new Dimension ( 500 , 50 ) ) ; gbc = new GridBagConstraints ( ) ; gbc . insets = new Insets ( ButtonRow . BUTTON_SEP , 0 , 0 , 0 ) ; gbc . gridwidth = GridBagConstraints . REMAINDER ; gbc . anchor = GridBagConstraints . NORTHWEST ; gbc . fill = GridBagConstraints . BOTH ; gbc . weighty = 1 ; add ( scrollPane , gbc ) ; }
creates a new list editor with the given underlying model . new elements are added to the tail of the list by default .
