设置一个JTable中某些单元格的背景色
来源:互联网 发布:域名和空间怎么绑定 编辑:程序博客网 时间:2024/05/16 09:58
Object [][] data={
{null, null, null, null,null,null,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, null, null, null, null,null}
};
String [] head={
"日", "一", "二", "三","四","五","六"
};
JTable jTable1=new JTable(data,head);
jTable1.setRowHeight(40);
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
JScrollPane jScrollPane1=new JScrollPane();
jTable1.setCellSelectionEnabled(true);
jTable1.setFont(new Font("SimSun", 0, 20));
jTable1.getTableHeader().setFont(new Font("SimSun",0, 20));
jTable1.getTableHeader().setReorderingAllowed(false);
jTable1.getTableHeader().setResizingAllowed(false);
jTable1.setEnabled(false);
TableColumn column=null;
for(int i=0;i<7;i++){
column=jTable1.getColumnModel().getColumn(i);
column.setPreferredWidth(60);
}
DefaultTableCellRenderer tcr = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
if((column == 0&&row!=3)||column == 6||(column == 3&&row==3))
setBackground(new java.awt.Color(255, 255, 0));
else
setBackground(new Color(255,255,255));
return super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
}
};
for(int i=0;i<7;i++){
jTable1.getColumn(head[i]).setCellRenderer(tcr);
}
jScrollPane1.setViewportView(jTable1);
- 设置一个JTable中某些单元格的背景色
- 设置一个JTable中某些单元格的背景色
- java swing jtable 给指定的(一个或多个)单元格设置背景色
- JTable中CheckBox单元格背景色渲染
- JTabel 背景设置半透明 与某些区域的单元格设置背景色
- 设置单元格背景色
- POI中设置单元格背景色
- JTable设置表头背景色
- fullCalendar设置单元格背景色
- POI 设置单元格背景色
- 一个牛人写的“设置jtable单元格颜色,以及jtable中实现复选框”的程序,备忘
- Excel2010关于设置单元格颜色和背景色的bug
- DevExpress GridControl 设置单元格 某一行的背景色
- 比较单元格的值并设置背景色
- DevExpress GridControl 设置单元格 某一行的背景色
- jTable 中单元格的颜色设置
- Swing之JTable篇设置表格选中行的前景色和背景色
- [jtable]设置复选框前景色与背景色
- JDBC事务的控制问题
- 2010 现在完成进行时...
- PuTTY Download Page - PuTTY 工具下载页
- JS去掉空格回车换行(转http://hi.baidu.com/niubore/blog/item/27c77b89ca1dead8fd1f102a.html)
- 我们都是好孩子!
- 设置一个JTable中某些单元格的背景色
- Wince的调试串口修改
- JS判断输入是否为整数的正则表达式
- bash command line editing
- GCC中的弱符号与强符号
- XmlHttpRequest对象使用实例
- Google checkout 自己写的,免费了啊!
- Android Permission 中文说明
- IText入门必读