Another feature of an Electronic Trading User Interface is the notion of flashing cells on data update. The way I have decided to implement this feature is by using a custom renderer (TableCellRenderer) and what I call a DelayedCellOff class. Each cell in the grid is implemented as a Cell object. This Cell object has a flag that says if the cell should be flashed or not (if the cell value is for example different than the previous one).
When a cell is updated, fireTableCellUpdated is called on the model (DefaultTableModel), and if its flash status is true, a DelayedCellOff object referencing the cell object is added to a DelayQueue with a timeout.
Initially the cell is rendered with its flash foreground and background colours, and when the timeout expires, the cell flash state is reset; another fireTableCellUpdated is called, the renderer redraws the cell with its default background and foreground colours.
This implementation has two good qualities in my view: simplicity and efficiency.
File generation with SBT
4 years ago