Drawing a line on a BufferedImage

I'm trying to draw a line on a BufferedImage. The start point of the line is where the mouse is clicked and the end point is where the mouse is released. I want the line to be displayed as the mouse is dragging.

Is there a way to do this without repainting the image every time the mouse moves while dragging? The image is big and repainting is slow.

[365 byte] By [CanesVa] at [2007-11-27 8:40:12]
# 1
Use the repaint(...) method where you can specify the rectangle you want to repaint.
camickra at 2007-7-12 20:38:32 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks, that will help but when the line gets long I will still be repainting most of the image. Is there any way to avoid this?
CanesVa at 2007-7-12 20:38:33 > top of Java-index,Desktop,Core GUI APIs...
# 3
Use xor mode.See my example here: http://forum.java.sun.com/thread.jspa?threadID=5180039&tstart=60When using xor the second time you paint the same pixel it returns to its original value.
Rodney_McKaya at 2007-7-12 20:38:33 > top of Java-index,Desktop,Core GUI APIs...
# 4
Thanks!
CanesVa at 2007-7-12 20:38:33 > top of Java-index,Desktop,Core GUI APIs...