Skip to content

Instantly share code, notes, and snippets.

@ny83427 ny83427/Sample.java
Created Jan 18, 2019

Embed
What would you like to do?
Double Buffer Avoid Flashing
private Image bgImage;
@Override
public void update(Graphics g) {
if (bgImage == null) bgImage = this.createImage(WIDTH, HEIGHT);
Graphics bg = bgImage.getGraphics();
bg.setColor(Color.BLACK);
bg.fillRect(0, 0, WIDTH, HEIGHT);
this.paintComponent(bg);
}
@Override
protected void paintComponent(Graphics g) {
// painting stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.