我有我的自定義單元格渲染器,並且想要刪除單元格的邊框。
我該怎麼做?我試過setBorder但它不起作用。刪除jtable中的單元格邊框
這裏是我的渲染代碼:
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;
}
}
setShowXX()爲我工作,謝謝。 – harshit 2010-07-06 15:40:09
您可以同時使用[setShowGrid()](http://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html#setShowGrid(boolean)) – 2012-09-06 08:35:59
@WimDeblauwe謝謝,我錯過了那一個 – 2012-09-06 13:57:57