paint - java double buffer doesn't erase -
i doing project double buffering. when paint, paints on top of old layers, need erase them. repaint() didn't work, i'm guessing equally simple answer.
any ideas?
added code, , disappears, erases background color.
public void paint(graphics g) { super.paint(buffer); for(projectile p: projectiles) drawrectimage(buffer, p.image, p.getrectangle());
}
suggestions:
- if swing gui, don't override paint method, instead override
paintcomponent
method. won't current problem, prevent future problems including problems painting of borders , child components. - if swing (again don't say), make sure painting component extends jpanel, not jcomponent, since jpanel opaque , fills background rectangle in super method.
- if it's not swing, should consider changing awt swing.
- if you're still stuck, yep, you'll want create , post minimal example program. please check out link.
Comments
Post a Comment