我有我的自定义单元格渲染器,并且想要删除单元格的边框。
我该怎么做?我试过 setBorder 但它不起作用。
这是我的渲染器代码:
public class MyTableCellRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = -1195682136616306875L;
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
if (!isSelected) {
if (row % 2 == 0 && row != 1) {
c.setBackground(new Color(255, 255, 150));
} else {
c.setBackground(Color.WHITE);
}
} else {
c.setBackground(new Color(255, 230, 255));
}
c.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
return c;
}
}