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 .
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.
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 >

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
> 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.