【发布时间】:2012-07-15 12:19:24
【问题描述】:
我的项目中有一个名为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);
}
如何帮助我解决这个问题?
【问题讨论】:
-
你真的应该在问之前做一些研究。这是一件非常常见且容易做到的事情。 stackoverflow.com/a/3550006/933756