The following code should draw a blue, filled, circle of diameter 4 that corresponds to the movement of the mouse. Find the error(s) in the following code:

```
1 public void paintComponent( Graphics g )
2 {
3 if ( currentPoint != null )
4 {
5 g.fillOval( Color.BLUE, currentPoint.y, currentPoint.x, 4, 5 );
6 }
7
8 } // end method paintComponent
```


The color of the shape must be set using the setColor method of the Graphics class; it should not be specified in the call to the fillOval method. The x and y coordinates of the Point object are reversed. A circle is an oval with the same width and height, so the last argument sent to the fillOval method should be 4. The corrected code is listed below.
```
1 public void paintComponent( Graphics g )
2 {
3 if ( currentPoint != null )
4 {
5 g.setColor( Color.BLUE );
6 g.fillOval( currentPoint.x, currentPoint.y, 4, 4 );
7 }
8
9 } // end method paintComponent
```

Computer Science & Information Technology

You might also like to view...

In the Student Registration System, give an example of a schedule in which a deadlock occurs.

What will be an ideal response?

Computer Science & Information Technology

Case-based Critical Thinking QuestionsCase 12-1Casey is using XML to store information about the students in the science classes that he teaches. He wants to design a DTD that he can use to validate the XML documents that he uses for this purpose, and he comes to you for help. Casey wants to include a declaration for an element named "note" that can contain any type of content. Which of the following is an appropriate element declaration for this element?

A. B. C. D.

Computer Science & Information Technology

In the accompanying illustration, item F shows which step in the podcasting process?

A. When you use the aggregator or browser to access the content B. When you save the content to the Web server C. When you create the content and record it D. When you download the content to an RSS feed

Computer Science & Information Technology

Which of the following will occur if %temp% is executed from the run command?

A. The operating systems temporary folder will be opened. B. Applications located the %temp% folder will be executed. C. Applications will be deleted in the %temp% folder. D. The current users temporary folder will be opened.

Computer Science & Information Technology