Creating object of the class with paint method
<p>I created a menu with some options to choose. One of those options is "Play with computer" which starts the game.</p>

<pre><code>        JButton ai = new JButton("Play with computer");
    ai.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GameBoard play = new GameBoard();
            hi.dispose(); //jframe
        }
    });
</code></pre>

<p>And then comes GameBoard:</p>

<pre><code>@SuppressWarnings("serial")
public class GameBoard extends Canvas {
    private Image dbi;
    private Graphics db;
    private JFrame okno;
    Rectangle aiPaddle = new Rectangle(10, 590, 10, 50);
    Rectangle pPaddle = new Rectangle(10, 100, 10, 50);
    Rectangle ball = new Rectangle(560, 10, 10, 10);
    Player p = new Player(this);
    Ai a = new Ai(this);
    Ball b = new Ball(this);
    GameBoard() {
        okno = new JFrame();
        okno.setTitle("Pink Ponk");
        okno.setSize(600, 300);
        okno.getContentPane().setBackground(Color.black);
        okno.setResizable(false);
        okno.setVisible(true);
        okno.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        addKeyListener(p);
    }

    public static void main(String[] args) {
        GameBoard gra = new GameBoard();
        gra.okno.add(gra);
    }

    @Override
    public void update(Graphics g) {
        dbi = createImage(10, 50);
        db = dbi.getGraphics();
        paint(db);
        g.clearRect(0, 0, 600, 300);
        g.setColor(Color.white);
        g.drawRect(p.getX(), p.getY(), 10, 50);
        g.fillRect(p.getX(), p.getY(), 10, 50);
        g.drawOval(b.getX(), b.getY(), 10, 10);
        g.fillOval(b.getX(), b.getY(), 10, 10);
        g.drawRect(a.getX(), a.getY(), 10, 50);
        g.fillRect(a.getX(), a.getY(), 10, 50);
    }

    @Override
    public void paint(Graphics g) {
        pPaddle = new Rectangle(p.getX(), p.getY(), 10, 50);
        aiPaddle = new Rectangle(a.getX(), a.getY(), 10, 50);
        ball = new Rectangle(b.getX(), b.getY(), 10, 10);
        g.clearRect(0, 0, 600, 300);
        g.setColor(Color.white);
        g.drawRect(p.getX(), p.getY(), 10, 50);
        g.fillRect(p.getX(), p.getY(), 10, 50);
        g.drawOval(b.getX(), b.getY(), 10, 10);
        g.fillOval(b.getX(), b.getY(), 10, 10);
        g.drawRect(a.getX(), a.getY(), 10, 50);
        g.fillRect(a.getX(), a.getY(), 10, 50);
    }

}
</code></pre>

<p>I'm sure it should work, but it does not. I'm getting black screen, without any rectangles or ovals. Threads from other classes are working, because I'm still losing the game. :)</p>
