jTable行的背景颜色在我点击表头进行数据排序后不跟随排序进行变化,怎么解决?
我用渲染改变的颜色:cTable1.setDefaultRenderer(Object.class,newDefaultTableCellRenderer(){@Over...
我用渲染改变的颜色:
cTable1.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
float rate = (Float) table.getModel().getValueAt(row, 5);
if (rate>100) {
comp.setForeground(Color.red);
}else{
comp.setForeground(Color.black);
}
return comp;
}
}); 展开
cTable1.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
float rate = (Float) table.getModel().getValueAt(row, 5);
if (rate>100) {
comp.setForeground(Color.red);
}else{
comp.setForeground(Color.black);
}
return comp;
}
}); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询