我的项目中有一个名为tasktable的表。它从数据库(oracle)中检索数据。如何更改具有单元格ex中的颜色的行的颜色。(i,8)当我点击刷新按钮时自动?
我曾多次尝试将该源代码放在特定的行上,但最终导致整个表格着色:
int count;
count = tasktable.getRowCount();
for (int i=0;i<count;i++)
{
rr = new Object ();
rr = tasktable.getModel().getValueAt(i,8);
if(rr.equals("GREEN"))
{
setBackground(Color.GREEN);
}
if(rr.equals("red"))
{
setBackground(Color.red);
}
if(rr.equals("BLUE"))
{
setBackground(Color.BLUE);
}
if(rr.equals("yellow"))
{
setBackground(Color.yellow);
}
if(rr.equals("pink"))
{
setBackground(Color.pink);
}
if(rr.equals(null))
{
setBackground(null);
}如何才能帮助我解决这个问题?
发布于 2012-07-17 00:00:13
Component comp = super.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, col);
String s = table.getModel().getValueAt(row, VALIDATION_COLUMN ).toString();
comp.setForeground(Color.red);http://www.java-forums.org/awt-swing/541-how-change-color-jtable-row-having-particular-value.html
https://stackoverflow.com/questions/11507913
复制相似问题