The probable cause is you've overridden one of the paint methods and not called its equivalent super method.
Remember paint does a lot of important things, like panting the background. The probable cause is you've overridden one of the paint methods and not called its equivalent super method.
Remember paint does a lot of important things, like panting the background.
Take a look at Performing Customing Painting for more details
Updated
This is your problem right here...
public void paint(Graphics g) {
Image dbImg = createImage(getWidth(), getHeight());
Graphics dbg = dbImg.getGraphics();
draw(dbg);
g.drawImage(dbImg, 0, 0, this);
}
The basic problem is, you've broken the paint chain, meaning that all the important work that paint does, like paint the background, isn't getting done.
Also, Swing components are already double buffered, so you don't need to use createImage
and you shouldn't be overriding paint
, but instead paintComponent
So, get rid of paint
and use...
protected void paintComponent(Graphics g) {
super.paintComponent(g);
draw(g);
}
Instead... Take a look at Performing Customing Painting for more details