I have a problem with jtable, i wanna build a jtable, when i change cell value (using setValueAt() or any way), background color of this cell will be changed to a specified color (ex: Color.RED), after 500ms, it will be changed to default background color (ex: Color.BLACK), i'm using thread, but it can not resolve my problem, here's my sample code:
A renderer is shared by all cells in column so its values are always reset to the defaults before the cell is painted. So every time the cell is repainted the background will be reset to red. So what you really need is a method in your renderer that indicates if the cell should be painted in its default color or the blinking color. You would turn this on when you need it to blink and then each blink should turn it off.
Also, table.repaint() is not the way to do this. This will cause all the cells to be repainted. You should use the AbstractTableModel.fireTableCellUpdate(...) to invoke repainting of a specific cell.
Rob Camick wrote:A renderer is shared by all cells in column so its values are always reset to the defaults before the cell is painted. So every time the cell is repainted the background will be reset to red. So what you really need is a method in your renderer that indicates if the cell should be painted in its default color or the blinking color. You would turn this on when you need it to blink and then each blink should turn it off.
Also, table.repaint() is not the way to do this. This will cause all the cells to be repainted. You should use the AbstractTableModel.fireTableCellUpdate(...) to invoke repainting of a specific cell.
Thank for your help, i'll try, but in this case, i change bgcolor in setValue() method, so i can not pass 2 agr row and column to AbstractTableModel.fireTableCellUpdate(...) (where can i take it), can you show me an example, thank very much.