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 48 49 50 51 52 53
|
public class JXMapContextTableNodeRenderer implements TableCellRenderer{
private static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
/** Creates a new instance of ASMutableCellRenderer */
public JXMapContextTableNodeRenderer() {
super();
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JPanel comp = new JPanel(new GridLayout(1,1));
Object o = table.getValueAt(row,column);
comp.setOpaque(true);
if (isSelected) {
comp.setForeground(table.getSelectionForeground());
comp.setBackground(table.getSelectionBackground());
} else {
comp.setForeground(table.getForeground());
comp.setBackground(table.getBackground());
}
if(o instanceof Boolean){
JCheckBox c = new JCheckBox();
c.setHorizontalAlignment(JLabel.CENTER);
c.setBorderPainted(true);
if (isSelected) {
c.setForeground(table.getSelectionForeground());
c.setBackground(table.getSelectionBackground());
} else {
c.setForeground(table.getForeground());
c.setBackground(table.getBackground());
}
c.setSelected((value != null && ((Boolean)value).booleanValue()));
if (hasFocus) {
c.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
} else {
c.setBorder(noFocusBorder);
}
comp.add(c);
}
return comp ;
}
} |
Partager