Detect JTable repaint without subclassing JTable

I'm working on a plugin that adds drag and drop functionality to a JTable in the main program, so I need to work with the existing JTable object rather than creating a subclass. Everything's working fine so far except for my attempts to draw an arrow over the JTable that indicates the drag path. I can draw the arrow on mouse events, but there are other repaints that cause it to flicker and disappear.

Anyone know how I can detect repaints or another way to slip in my own painting code?

[504 byte] By [bemacea] at [2007-11-27 2:12:37]
# 1

Here's a thought, no idea if it will work:

Toolkit.getDefaultToolkit.addAWTEventListener(new AWTEventListener() {

public void eventDispatched(AWTEvent e) {

if (e.getSource().equals(<your table>)) {

// repaint your arrow

}

}

},

AWTEvent.PAINT_EVENT_MASK);

mpmarronea at 2007-7-12 2:07:11 > top of Java-index,Desktop,Core GUI APIs...
# 2
you can try to subclass the table's container. E.g. JScrollPane or JViewPort of the JScrollPane. You can override their paint(), Call super.paint() and add your drawings after that.regards,Stas
StanislavLa at 2007-7-12 2:07:11 > top of Java-index,Desktop,Core GUI APIs...
# 3
Thanks mpmarrone, that was a good thought. Unfortunately the only PAINT_EVENTs I'm seeing are when the visibility of a window changes. I suppose it would be horribly slow if it actually fired an event for every repaint.
bemacea at 2007-7-12 2:07:11 > top of Java-index,Desktop,Core GUI APIs...