public class GamePanel extends JPanel implements Runnable {
public static final int GAME_WIDTH = 600; public static final int GAME_HEIGHT = 600; public static final int LEFT_PADDLE_FROM_LEFT = 10; public static final int RIGHT_PADDLE_FROM_RIGHT = 10;
public static final int MOVE_PADDLE_UP = 1; public static final int MOVE_PADDLE_DOWN = 2; public static final int NO_MOVE = 0;
private int leftPaddleMovementStatus; private int rightPaddleMovementStatus;
public void gameUpdate(){ //check that paddle does not run of screen, if safe move the paddle if(leftPaddle.getPoint().y > 0 && leftPaddle.getPoint().y < GAME_HEIGHT - Paddle.HEIGHT){
I believe that createImage() is going to return null until the component is actually on-screen. Doing lazy initialization of the image at the first call to paint() on the event thread would work, but because you're calling paint() yourself (which is rarely the great idea that people always think it is!) you don't actually have a good way to know when that will be, other than trying, sleeping, and trying again.
Moving to the Swing/AWT/SWT/JFace forum for any further discussion.
Notice, for example that the object returned from getGraphics is ignored.
I would suggest that you simplify the code -- there's no need to do this sort of double buffering, because Swing already does double buffering for you! Also, javax.swing.Timer is a better way to drive simple animation.