package com.vci.client.ui.table;
|
|
import java.awt.Component;
|
import java.awt.event.ItemEvent;
|
import java.awt.event.ItemListener;
|
import javax.swing.DefaultCellEditor;
|
import javax.swing.JCheckBox;
|
import javax.swing.JTable;
|
|
public class CheckBoxEditor extends DefaultCellEditor implements ItemListener{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1931785262484450574L;
|
private JCheckBox checkBox;
|
public CheckBoxEditor(JCheckBox checkBox) {
|
super(checkBox);
|
}
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean
|
isSelected, int row, int column){
|
if(value == null){
|
return null;
|
}
|
|
checkBox = (JCheckBox)value;
|
table.setEditingRow(row);
|
table.setEditingColumn(column);
|
checkBox.addItemListener(this);
|
|
return (Component)value;
|
|
}
|
|
public Object getCellEditorValue(){
|
checkBox.removeItemListener(this);
|
return checkBox;
|
|
}
|
@Override
|
public void itemStateChanged(ItemEvent e) {
|
super.fireEditingStopped();
|
}
|
|
}
|