There are several .png images that replace each other on the form. The only problem is that when drawing a new image, the previous one is not cleared.
Currently I have the following:
BufferedImage image = null; public void changeFrame(BufferedImage newImage){ image = newImage; repaint(); } public void update(Graphics g){ paint(g); } public void paint(Graphics g) { bf = new BufferedImage( width,height, BufferedImage.TYPE_INT_ARGB); try{ animation(bf.getGraphics()); g.drawImage(bf,0,0,null); }catch(Exception ex){ } } public void animation(Graphics g) { //super.paint(g); g.drawImage(image, 0, 0, this); }
Thus, the images overlap each other when a changeFrame
called with a new image. And if you uncomment super.paint(g);
then the background will be filled with white. And I need a transparent background. I have already tried everything, I ask for help.