drawing image on frame..

hi frens..Is there way of drawing an image on Frame without erasing previous image. Each time the repaint() is called for drawing new image on frame using Graphics object, repaint() just clears the previous images , but i want previous image to be sustained .
[273 byte] By [abhaykumara] at [2007-10-3 6:08:41]
# 1
Havent tried it, but you could try drawing everything onto a BufferedImage, then only drawing the BufferedImage in the paint method.
CaptainMorgan08a at 2007-7-15 0:51:48 > top of Java-index,Other Topics,Java Game Development...
# 2
you need to override the draw method and add the images together using JAI, that or draw pixels or 2D object on the same buffer but if you're wanting to maintain 2 distinct images, then you need to add the new image to the panel or whatever.
SoulTech2012a at 2007-7-15 0:51:48 > top of Java-index,Other Topics,Java Game Development...
# 3

What I would suggest Is a more sophisticated approach, Take the graphics object from container using:-

Graphics g = container.getGraphics();

Then draw whatever you want to on g, as you do in paint. it like defining your own implementation and nullifying repaint().

But repaint is also called on window resizing etc. for that you can override update() method.

DANa at 2007-7-15 0:51:48 > top of Java-index,Other Topics,Java Game Development...
# 4
Override the update() method of the panel to just call paint(). By default it clears to the background colour first, and then calls paint().Try googling for "Painting in AWT and Swing" for more details.Oops - slow replyMessage was edited by: TimRyanNZ
TimRyanNZa at 2007-7-15 0:51:48 > top of Java-index,Other Topics,Java Game Development...
# 5

> hi frens..

> Is there way of drawing an image on Frame

> without erasing previous image. Each time the

> repaint() is called for drawing new image on frame

> using Graphics object, repaint() just clears the

> previous images , but i want previous image to be

> sustained .

ImageIcon WhiteIcon = new ImageIcon("White.GIF");

JL = new JLabel(null ,WhiteIcon, 0 );

f.add(JL);

Hope this will do.

AdityaGamera at 2007-7-15 0:51:48 > top of Java-index,Other Topics,Java Game Development...