124k views
2 votes
Complete the code, drawing a solid circle (with the current color, whatever it is) so that its diameter is 200, and the coordinates of its center are ( 250, 150 )

public void paint( Graphics g )

{

// your code goes here

}

User Troy Brant
by
7.8k points

1 Answer

5 votes

Answer:

public void paint( Graphics g )

{

g.drawOval(150, 50, 200, 200); //Draw a circle

}

Step-by-step explanation

drawOval( int X, int Y, int width, int height ) this instruction draws an oval in the specified 'x' and 'y' coordinates, been this coordinates the left upper corner of a rectangle who perfectly fits the oval. The last two numbers are the width and height.

X coordinate from the upper left corner. From the center location, move half of the width of the circle. (minus 100)

Y coordinate from the upper left corner. From the center location, move half of the height of the circle. (minus 100)

User Martin Seeler
by
7.4k points