Can't change color
<p>Hello I am creating a application ( exercise ) in Java where I have to change the color of a variable in my drawing class. when the application starts and I run a sysout on the color variable it says null but when I press my right mouse button for example it changes color in the controller class but not in my drawing class.. Can someone take a look and tell me what i am doing wrong? </p>

<p>here is a piece of code</p>

<p>this is the relevant part of the drawing class</p>

<pre><code>    private Color color;
private ArrayList&lt;Point&gt; p = new ArrayList&lt;Point&gt;();

public Drawing(Color color) {
    this.color = color;
    System.out.println("color  " + color);
}

public void draw(Graphics g) {
    for(int i = 0; i &lt; p.size(); i++) {
        g.setColor(color);
        g.fillRect(p.get(i).x, p.get(i).y, 10, 10);
    }
}
</code></pre>

<p>and this is the relevant code of my controller.</p>

<pre><code>Color color; // kleur vasthouden
Drawing draw; // class definieren
private ArrayList&lt;Drawing&gt; tekening = new ArrayList&lt;Drawing&gt;();
int x, y;

public DrawingPanel() {
    setBackground(Color.WHITE); // zorg voor een witte achtergrond.
    this.addMouseListener(this); // control de mouselistener
    draw = new Drawing(color);
}

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    draw.draw(g);
}

@Override
public void mouseClicked(MouseEvent e) {

    if(e.getButton() == MouseEvent.BUTTON1) {
        Point k = new Point(e.getX(), e.getY());

        draw.addPoint(k);
        System.out.println("punt gezet op " + k);
    }
    if(e.getButton() == MouseEvent.BUTTON3) {
        color = new Color(r.nextInt(255 - 0 + 1) + 0, r.nextInt(255 - 0 + 1) + 0, r.nextInt(255 - 0 + 1) + 0);
        System.out.println("new color " + color);
    }
    repaint();
}
</code></pre>

<p>I hope someone can figure out what i'm doing wrong..</p>
