Originally posted by David Irwin:
I have a JTable and a custom ImageIcon class for one particular column in my table. The custom ImageIcon class is used to overlay and fade in/fade out a small additional image on the background image (think of a small recording icon that fades in and out when recording is taking place for a given row).
Everything works well except for getting the cell to update. If I move my mouse in and out of the cell then the small overlay icon updates, but if I just leave the cell alone it doesn't update.
...
I'm using the TimingFramework to actually do the timing. Here's a snippet from the timing target:
I currently don't call a repaint() on the actual JTable after the Alpha component has been updated. Do I need to do this?
You do need to force the table to actually redraw the icon, but calling
repaint() on the JTable is not the correct way to do this. What you want
to do in the timing event is have the table model call
fireTableCellUpdated() for the cell(s) in question.
Are you already extending AbstractTableModel for your table model? If so
it's probably easiest to just do all the timer stuff from within your model.
[edit: btw, ImageIcon.component.repaint() doesn't do what you think it does.
In fact, it does nothing. For one, ImageIcon.component is static and shared
by all ImageIcons. It is used only by the loadImage() method, and then only
indirectly by ImageIcon's static MediaTracker. The API probably shouldn't have
exposed it.]
[ May 27, 2008: Message edited by: Brian Cole ]