How to draw a RGB Color Wheel in Java
<p>I am trying to draw a RGB color wheel in Java, but I can't get the gradient by a circular shape. I just want to draw it on screen, with no user interaction at all.</p>

<p>This is all I have for now:</p>

<pre><code>public void paint (Graphics g){
        super.paint(g);

        int red = 255;
        int green = 0;
        int blue = 0;
        int x1 = 500;
        int y1 = 305;
        int x2 = 500;
        int y2 = 50;

        while (green != 255){
            g.setColor(new Color(red, green, blue));
            green++;
            g.drawLine(x1, y1, x2, y2);
            x2++;
            if (y2 &lt; y1){
                y2++;
            }
        }
        while (red != 0){
            g.setColor(new Color(red, green, blue));
            red--;
            g.drawLine(x1, y1, x2, y2);
            x2--;
            y2++;
        }
        x2 = 500;
        while (blue != 255){
            g.setColor(new Color(red, green, blue));
            blue++;
            g.drawLine(x1, y1, x2, y2);
            x2--;
            if (y2 &gt; y1){
                y2--;
            }
        }

        while (red != 255){
            green--;
            g.setColor(new Color(red, green, blue));
            red++;
            g.drawLine(x1, y1, x2, y2);
            x2++;
            y2--;
        }
    }                
}
</code></pre>

<p><a href="http://i.stack.imgur.com/HCKbX.png" rel="nofollow">Which draws the gradient like this</a></p>

<p>This is <a href="http://i.stack.imgur.com/XaoEM.png" rel="nofollow">what I want</a></p>