Target

This applet uses a private method to draw a circle using the coordinates of the centre and the radius. It then calls this method to draw a target.

import java.awt.*;
import java.applet.Applet;

public class Circle extends Applet
{

public void paint (Graphics g)
{

g.setColor (Color.red);
myCircle (g, 100, 100, 75);
g.setColor (Color.white);
myCircle (g, 100, 100, 65);
g.setColor (Color.red);
myCircle (g, 100, 100, 55);
g.setColor (Color.white);
myCircle (g, 100, 100, 45);
g.setColor (Color.red);
myCircle (g, 100, 100, 35);
g.setColor (Color.white);
myCircle (g, 100, 100, 25);
g.setColor (Color.black);
myCircle (g, 100, 100, 15);

}
private void myCircle (Graphics g, int xCoord, int yCoord, int radius)
{

g.fillOval (xCoord-radius, yCoord-radius, radius*2, radius*2);

}

}

This is the output

target.JPG
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License