展开全部
这是我62616964757a686964616fe59b9ee7ad9431333332393336以前做的:
public Component getTableCellRendererComponent(JTable table,Object value,
boolean isSelected,boolean hasFocus,int row,int column)
{
//如果是图标,就要显示图标,否则就显示文本
if(value instanceof Icon)
this.setIcon((Icon)value);
else
this.setText(value.toString());
//如果被选中
if(isSelected)
//设置选定单元格的背景色。单元格渲染器可以使用此颜色填充选定单元格。
//返回选定单元格的背景色。
super.setBackground(table.getSelectionBackground());
else
this.setBackground(table.getBackground());
//设置居中
this.setHorizontalAlignment(JLabel.CENTER);
this.setToolTipText(value.toString());
return this;
}
ps.要在JTable中添加这个渲染器。
样式: