daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ComboBoxCellEditor extends AbstractCellEditor implements TableCellEditor {
  2.       private JComboBox jcb;
  3.  
  4.       private ArrayList<String> choice;
  5.  
  6.       public ComboBoxCellEditor(ArrayList<String> choice) {
  7.          this.choice = choice;
  8.       }
  9.  
  10.       @Override
  11.       public JComponent getTableCellEditorComponent(JTable table, Object item, boolean isSelected, int row, int column) {
  12.          jcb = new JComboBox(choice.toArray());
  13.          jcb.setEditable(true);
  14.          if (item != null) {
  15.             jcb.setSelectedItem(item);
  16.          }
  17.          return jcb;
  18.       }
  19.  
  20.       @Override
  21.       public Object getCellEditorValue() {
  22.          return jcb.getSelectedItem();
  23.       }
  24.    }
RAW Paste Data
Top