//参考以下代码DefaultTableCellRenderer cellRender = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) { this.setHorizontalAlignment(JLabel.RIGHT); if (row == 0) { //如果是表示星期的单元格
this.setBackground(Color.GRAY);
//如果是表示今天的单元格
} else if (value != null && ((String) value).equals("" + day)) {
this.setBackground(Color.PINK);
} else { //其余的单元格
this.setBackground(Color.WHITE);
} return super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
}
}; calendar.setDefaultRenderer(Object.class, cellRender);//calendar为表格
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) { this.setHorizontalAlignment(JLabel.RIGHT); if (row == 0) { //如果是表示星期的单元格
this.setBackground(Color.GRAY);
//如果是表示今天的单元格
} else if (value != null && ((String) value).equals("" + day)) {
this.setBackground(Color.PINK);
} else { //其余的单元格
this.setBackground(Color.WHITE);
} return super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
}
}; calendar.setDefaultRenderer(Object.class, cellRender);//calendar为表格
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货