|
Say that you want a circle of radius 50 centered on the point (100, 300). What should the drawOval command look like? A good answer might be:
Of course the method would work if you did the arithmetic and put the results in the method call, but why bother?drawOval( 100-50, 300-50, 2*50, 2*50 ) | |
Drawing RectanglesTo draw a rectangle, use the drawRect method of the Graphics object. This method looks like: It draws the outline of a rectangle using the current pen color. The left and right edges of the rectangle are at x and x + width respectively. The top and bottom edges of the rectangle are at y and y + heigth respectively.drawRect(int x, int y, int width, int height) Of course, if you want a square you would use this method also. Here is an applet that surrounds the entire drawing area with a rectangle, then puts another rectangle in the center.
Here is what it draws on your screen: | |
QUESTION 14:What do you suppose the following method does?
Click Here after you have answered the question
|