I wanted to paint a render for stock ticks based on the previous value :
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Object o1 = table.getModel().getValueAt(row, column);
Object o2 = value;
}
Basically If value in o1 < o2 then paint RED If value in o1 > o2 then paint GREEN
Problem though is both o1 and o2 return the same value. How can I get the previous value contained in the renderer
If the model and the table have the same value at this point, then the model has already been updated. I don't think the table is a good place to expect to hold the "previous value"; I suggest instead trapping its change in the model and putting it somewhere reasonable there. It won't be accessible by a call defined in the TableModel interface, but then this concept doesn't exist there so we shouldn't expect it to be.