diff --git a/src/main/java/PingPong/GamePanel.java b/src/main/java/PingPong/GamePanel.java index 3b982e5..8c6e88a 100644 --- a/src/main/java/PingPong/GamePanel.java +++ b/src/main/java/PingPong/GamePanel.java @@ -18,6 +18,8 @@ public class GamePanel extends JPanel implements Runnable { Paddle paddle_1; Paddle paddle_2; Score score; + Image image; + Graphics graphics; public void run() { @@ -30,6 +32,12 @@ public class GamePanel extends JPanel implements Runnable { ball.draw(g); } + public void paint(Graphics g) { + image = createImage(getWidth(), getHeight()); + graphics = image.getGraphics(); + draw(graphics); + g.drawImage(image, 0, 0, this); + } public void newBall() {