Hi, i wanted to make a game, in which you can only move a single qube, around the screen, very simple to understand how rendering and such works.
Wrote the code, but of course it does not work, its not rendering properly and i cant find whats wrong! The screen flickers and i cant move anything..
I guess i havent understood something properly, the issue is in the frame, but for safety ill post everything involved (not much).
Any help would be appriciated!

The Frame:
Java Code:
package stuff;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;

import javax.swing.JFrame;

@SuppressWarnings("serial")
public class GamePanel extends JFrame implements Runnable, KeyListener
{
	Thread game;
	Graphics2D dbg;
	BufferedImage backbuffer;
	AffineTransform identity = new AffineTransform();
	
	Box box=new Box();
	
	GamePanel()
	{
		setSize(640,480);
		setBackground(Color.DARK_GRAY);
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		backbuffer=new BufferedImage(640,480, BufferedImage.TYPE_INT_RGB);
		dbg=backbuffer.createGraphics();
		box.setX(320);
		box.setY(240);
		game = new Thread(this);
		game.start();
		
		addKeyListener(this);
		
	}
	
	public void run()
	{
		Thread t=Thread.currentThread();
		while(t==game)
		{
			try
			{
				gameUpdate();
				update(dbg);
				Thread.sleep(50);
			}
			catch(InterruptedException e)
			{
				
			}
			repaint();
		}
	}

	public void gameUpdate()
	{
		updateBox();
	}
	
	public void update(Graphics g)
	{
		dbg.setTransform(identity);

		dbg.setPaint(Color.red);
		dbg.fillRect(0, 0, getSize().width, getSize().height);
		drawBox();
		
		paint(g);
	}
	
	public void updateBox()
	{
		box.incX(box.getVelX());
		if(box.getX()<0)
		{
			box.setX(getSize().width);
		}
		else if(box.getX()>getSize().width)
		{
			box.setX(0);
		}
		
		box.incY(box.getVelY());
		if(box.getY()<0)
		{
			box.setY(getSize().width);
		}
		else if(box.getY()>getSize().width)
		{
			box.setY(0);
		}
	}
	
	public void paint(Graphics g) 
	{
		g.drawImage(backbuffer, 0, 0, this);
		}
	
	public void drawBox()
	{
		dbg.setTransform(identity);
		dbg.translate(box.getX(), box.getY());
		dbg.rotate(Math.toRadians(box.getFaceAngle()));
		dbg.setColor(Color.CYAN);
		dbg.fill(box.getShape());
	}
	
	public double calcAngleMoveX(double angle)
	{
		return (double) (Math.cos(angle*Math.PI/180));
	}
	
	public double calcAngleMoveY(double angle)
	{
		return (double) (Math.sin(angle*Math.PI/180));
	}
	
	public void keyPressed(KeyEvent e) 
	{
		int key=e.getKeyCode();
		switch(key)
		{
		case KeyEvent.VK_LEFT:
			box.incMoveAngle(-5);
			if(box.getMoveAngle()<0)
			{
				box.setMoveAngle(360-5);
			}
			break;
			
		case KeyEvent.VK_RIGHT:
			box.incMoveAngle(5);
			if(box.getMoveAngle()>360)
			{
				box.setMoveAngle(5);
			}
			break;
			
		case KeyEvent.VK_UP:
			//box.setMoveAngle(box.getFaceAngle()-90);
			box.incVelX(calcAngleMoveX(box.getMoveAngle()));
			box.incVelY(calcAngleMoveY(box.getMoveAngle()));
		case KeyEvent.VK_DOWN:
			box.incVelX(-calcAngleMoveX(box.getMoveAngle()));
			box.incVelY(-calcAngleMoveY(box.getMoveAngle()));
		}
	}

	public void keyReleased(KeyEvent e) {}

	public void keyTyped(KeyEvent e) {}
	
	public static void main(String[] args) 
	{
		new GamePanel();
	}
}
The Box:
Java Code:
package stuff;

import java.awt.Polygon;
import java.awt.Rectangle;

public class Box extends BaseShape
{
	private int[] boxx={-10,10,10,-10};
	private int[] boxy={10,10,-10,-10};
	
	public Rectangle getBounds()
	{
		Rectangle r=new Rectangle((int)getX(), (int) getY(),6,6);
		return r;
	}
	
	Box()
	{
		setShape(new Polygon(boxx,boxy, boxx.length));
		setAlive(true);
	}

}
The Base:
Java Code:
package stuff;

import java.awt.Shape;

public class BaseShape 
{
	private Shape shape;
	private boolean alive;
	private double x,y;
	private double velX,velY;
	private double moveAngle, faceAngle;
	
	public Shape getShape()	{return shape;}
	public boolean isAlive(){return alive;}
	public double getX() {return x;}
	public double getY() {return y;}
	public double getVelX(){return velX;}
	public double getVelY(){return velY;}
	public double getMoveAngle(){return moveAngle;}
	public double getFaceAngle(){return faceAngle;}
	
	public void setShape(Shape shape) { this.shape = shape; }
	public void setAlive(boolean alive) { this.alive = alive; }
	public void setX(double x) { this.x = x; }
	public void incX(double i) { this.x += i; }
	public void setY(double y) { this.y = y; }
	public void incY(double i) { this.y += i; }
	public void setVelX(double velX) { this.velX = velX; }
	public void incVelX(double i) { this.velX += i; }
	public void setVelY(double velY) { this.velY = velY; }
	public void incVelY(double i) { this.velY += i; }
	public void setFaceAngle(double angle) { this.faceAngle = angle; }
	public void incFaceAngle(double i) { this.faceAngle += i; }
	public void setMoveAngle(double angle) { this.moveAngle = angle; }
	public void incMoveAngle(double i) { this.moveAngle += i; }
	
	BaseShape() 
	{
		setShape(null);
		setAlive(false);
		setX(0.0);
		setY(0.0);
		setVelX(0.0);
		setVelY(0.0);
		setMoveAngle(0.0);
		setFaceAngle(0.0);
	}
}