https://github.com/teerjk/VarSifter
Raw File
Tip revision: 7e57e5857b08f5253f28e96477fc211f67a0ffea authored by Jamie K. Teer on 27 April 2020, 14:42:41 UTC
-Documentation updates to point to github.
Tip revision: 7e57e58
JCheckBoxCellEditor.java
import javax.swing.*;
import javax.swing.table.*;
import java.awt.Component;

/**
*   Custom Editor to handle JCheckBox (as itself, not as boolean)
*/
public class JCheckBoxCellEditor extends AbstractCellEditor implements TableCellEditor {

    private JCheckBox cB;

    public JCheckBoxCellEditor() {
    }


    public Object getCellEditorValue() {
        return cB;
    }


    public Component getTableCellEditorComponent(JTable t,
                                                 Object value,
                                                 boolean isSelected,
                                                 int row,
                                                 int col) {
        cB = (JCheckBox)value;
        cB.setHorizontalAlignment(SwingConstants.CENTER);
        return cB;
    }
}
back to top