作者bypang (青菜萝卜)
看板java
标题Re: [问题] 如何改变JTable的Row Color?
时间Fri May 11 16:41:07 2007
感谢您的回答。
想法有点不太一样,前辈的做法是update符合的cell而已。
而我想要的是整个row的颜色。
不过,我已经试出方法了。
就是
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(table,
value, isSelected, hasFocus, row, column);
int VALIDATION_COL = 4;
boolean isEnabled = Boolean.parseBoolean(
table.getModel().getValueAt(row, VALIDATION_COL).toString());
if(isEnabled) {
cell.setBackground(Color.BLUE);
} else {
cell.setBackground(Color.RED);
}
return cell;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 219.95.190.120