I have created a JTable
that contains financial instruments prices.
I have connected the table to an online broker, and I receive live feeds through the API.
My table now correctly displays cells values changing when a new price comes in (I have created an "InstrumentListener".
What I want is this: when a cell value changes, the cell background color changes for 150ms and then returns white. If the value is higher than the previous cell value, the color should switch to Color1
, if the value is lower, the color should switch to Color2
.
Asked
Active
Viewed 480 times
1

Andrew Thompson
- 168,117
- 40
- 217
- 433

prre72
- 697
- 2
- 12
- 23
1 Answers
2
The tutorial article Using Custom Renderers shows how to change a table cell's background color. The tutorial article How to Use Swing Timers shows how to mark time efficiently; invoke setRepeats(false)
and restore the original color in actionPerformed()
. From a human factors perspective, 150 milliseconds is a little short. Consider fading the color, as shown here and here, over a second or so.