Rubber Band Box Over Tiff

M

Mike

I am trying to create a rubber band box over a tiff image. I am
currently using a tiledimage and also using getGraphics(). I can get
the rectangle to be drawn with the mouse, but I cannot get the
previous lines to erase, so eventually the screen will all turn black
if I keep moving the mouse around. I can redraw the lines in
white.... but how do I redraw them with the actual image?

Thank you in advance.
 
M

Michael Borgwardt

Mike said:
I am trying to create a rubber band box over a tiff image. I am
currently using a tiledimage and also using getGraphics(). I can get
the rectangle to be drawn with the mouse, but I cannot get the
previous lines to erase, so eventually the screen will all turn black
if I keep moving the mouse around. I can redraw the lines in
white.... but how do I redraw them with the actual image?

Assuming that you're using Swing:
Don't draw the box directly on the image, draw it on an otherwise
transparent component on top, i.e. use a JLayeredPane or (if
the layout is simple enough) the GlassPane of the JFrame.
 
A

ak

I can get
the rectangle to be drawn with the mouse, but I cannot get the
previous lines to erase, so eventually the screen will all turn black
if I keep moving the mouse around. I can redraw the lines in
white.... but how do I redraw them with the actual image?
g.setXORMode(Color c);

every line/rect must be painted _twice_.
when mouse moves, you first paint your last rect, then new rect. and so
on...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top