我創建一個dataTable和cellEditor一列。這個列簡單jSpinner。我有以下問題。當我在微調器中輸入一些值並選擇另一行時,上一行中的值將不會更改。如果我按下,它會完成。如果我選擇或按鈕,它也會完成。但是如果我輸入價值並改變選擇,它將不會完成。請幫助。這是CellEditor代碼。JSpinner更新
public class DurationTableCellEditor extends AbstractCellEditor implements TableCellEditor{
final JSpinner spinner = new JSpinner();
// Initializes the spinner.
public DurationTableCellEditor() {
spinner.setModel(new SpinnerNumberModel(1,1,50000,1));
}
// Prepares the spinner component and returns it.
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {
spinner.setValue(new Integer(value.toString()).intValue());
spinner.setCursor(null);
return spinner;
}
// Enables the editor only for double-clicks.
@Override
public boolean isCellEditable(EventObject evt) {
if (evt instanceof MouseEvent) {
return ((MouseEvent)evt).getClickCount() >= 1;
}
return true;
}
// Returns the spinners current value.
public Object getCellEditorValue() {
return spinner.getValue();
}
}