0
I’m making a graphical application with the class Component, but every time I delete the canvas to draw a new frame, Canvas flashes!
The clearBackground function:
public void clearBackground() {
Graphics g = bs.getDrawGraphics();
g.drawImage(background, 0, 0, null);
g.dispose();
bs.show();
}
background is the white color, but it blinks, and I’ve done everything to solve the problem, but whenever it renders, the Canvas blinks, but sometimes it stays without blinking, and soon after comes back! What can I do to solve the problem?
You are drawing inside a Jpainel instead of drawing directly inside a Jframe?
– Douglas
No. I only used the add(screen) function, where screen is Canvas. What you mean is to add in the Jframe contentPane?
– Taarak
"myFrame.add(myPanel)" where myFrame is a Jframe and myPanel is a Jpanel, then you draw in Jpanel, try this.
– Douglas