Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. (TCO 4) In order to handle an event from a JButton object button1, what does

ID: 3661135 • Letter: 1

Question

1.(TCO 4) In order to handle an event from a JButton object button1, what does a programmer need to do?(Points : 6) Create a nested inner class that implements the ActionListener interface.
Create an object of the nested inner class as the event handler object.
Invoke the addActionListener method on button1 to register the event handler object with the event source.
All of the above.



2.(TCO 5) Which of the following draws a circle whose center position is (400, 400) and whose radius is 50?(Points : 6) g.drawCircle(350, 350, 100, 100);
g.drawOval(350, 350, 100, 100);
g.drawCircle(400, 400, 50, 50);
g.drawOval(400, 400, 50, 50);




3.(TCO 5) The x, y drawing coordinate system used in Java graphics(Points : 6) uses character units.
has the origin in the upper left corner of the display area.
uses the x coordinate for the vertical axis.
All of the above.



4.(TCO 5) In order to draw an orange circle, you must first(Points : 6) draw the circle and then set the color using circle.setColor(ORANGE);.
set the color on the graphics object by doing g.setColor(Color.ORANGE);.
set the circle color by doing circle.setColor(ORANGE);.
set the background color to Color.ORANGE and then draw the circle.



5.(TCO 5) In order to get an event associated with a mouse click and determine the position of the mouse cursor when the click happened, a Java program must(Points : 6) implement the MouseMotionListener interface and use the MouseMotionEvent to get the position.
implement the MouseEventListener interface and use the getX and getY methods to get the position..
implement the MouseListener interface and use the MouseEvent object parameter to the mouseClicked method to get the position.
implement the MouseEvent interface and use the getX and getY methods to get the position.



1.(TCO 4) In order to handle an event from a JButton object button1, what does a programmer need to do?(Points : 6) Create a nested inner class that implements the ActionListener interface.
Create an object of the nested inner class as the event handler object.
Invoke the addActionListener method on button1 to register the event handler object with the event source.
All of the above.


Explanation / Answer

All of the above g.drawOval(400, 400, 50, 50); has the origin in the upper left corner of the display area set the color on the graphics object by doing g.setColor(Color.ORANGE); implement the MouseEvent interface and use the getX and getY methods to get the position.