if (selectedFlag != null) {
selectionColumn = table.getColumn(selectedFlag.getName());
selectionColumn.setPreferredWidth(40);
selectionColumn.setMaxWidth(40);
selectionColumn.setCellRenderer(new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
boolean selected = false;
if (value instanceof Boolean) {
selected = ((Boolean) value).booleanValue();
}
JComponent ret = getCheckBoxCellRendererComponent();
cellRendererCheckBox.setSelected(selected);
if (isSelected) {
ret.setBackground(SystemColor.textHighlight);
ret.setForeground(SystemColor.textHighlightText);
ret.setOpaque(true);
} else {
ret.setForeground(SystemColor.text);
ret.setOpaque(false);
}
return ret;
}
});
selectionColumn.setHeaderRenderer(new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
return getSelectionHeaderRenderer();
}
});