예제 #1
0
 @Override
 public boolean stopCellEditing() {
   if (myValue != null) {
     if (myValue.isBoolean()) {
       myValue.setValue(myCheckBox.isSelected());
     } else {
       myValue.setValue(myField.getText().trim());
     }
   }
   revaliateActions();
   return super.stopCellEditing();
 }
예제 #2
0
 @Nullable
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   myValue = ((MyTableModel) table.getModel()).getRegistryValue(row);
   if (myValue.asColor(null) != null) {
     final Color color =
         ColorChooser.chooseColor(
             table, "Choose color", ((RegistryValue) value).asColor(Color.WHITE));
     if (color != null) {
       myValue.setValue(color.getRed() + "," + color.getGreen() + "," + color.getBlue());
     }
     return null;
   } else if (myValue.isBoolean()) {
     myCheckBox.setSelected(myValue.asBoolean());
     myCheckBox.setBackground(table.getBackground());
     return myCheckBox;
   } else {
     myField.setText(myValue.asString());
     myField.setBorder(null);
     myField.selectAll();
     return myField;
   }
 }