ludc
2024-09-14 36c2449aec5b51e5ed4e5c6841154b746060e09a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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();
    }
    
}