File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes how to draw lines without change background's image? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to draw lines without change background Watch "how to draw lines without change background New topic
Author

how to draw lines without change background's image?

eric zheng
Greenhorn

Joined: Jun 27, 2003
Posts: 5
I draw an image in Jpanel as background,and following want to achieve lines or circles movement on the panel. however, when the line move using draw a white color line to overwrite, the background's image changed as well. how can I achieve move the lines without change the image?
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Norm Miller
Ranch Hand

Joined: May 21, 2002
Posts: 56
Pursuing this answer a bit further:

Is there any good to be gained by taking advantage of the various layers that the Swing model makes available? I.e., draw the image as shown, but put the ball on the Transparent layer.

If you want to mouse click on the ball, does the answer remain the same?

Thanks
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Is there any good to be gained by taking advantage of the various layers that the Swing model makes available? I.e., draw the image as shown, but put the ball on the Transparent layer.

I don't notice any advantage. It seems like one advantage of drawing on a transparent top layer would be to preserve the drawing while we swap or manipulate the image below.

If you want to mouse click on the ball, does the answer remain the same?

It seems to. Let's try it and see:
Norm Miller
Ranch Hand

Joined: May 21, 2002
Posts: 56
That is very neat!

Thank you.
eric zheng
Greenhorn

Joined: Jun 27, 2003
Posts: 5
Thanks a lot!
 
jQuery in Action, 2nd edition
 
subject: how to draw lines without change background's image?