Consider an applet that implements MouseListener. Assume that the applet has five instance data, int x1, x2, y1, y2, and boolean inside. The four int values represent the two end-points of a box (x1, y1 is the upper left hand point and x2, y2 is the lower right hand point) . Which of the following properly defines code that will determine whenever the mouse button is clicked if the mouse is currently inside this box or not. If the mouse is inside the box, inside is set to True, otherwise it is set to false.
A) public void mouseMoved(MouseEvent me) {
If (me.getX( ) >= x1 && me.getX( ) <= x2 && me.getY( ) >= y1 && me.getY( ) <= y2)
Inside = True;
Else
Inside = false;
}
B) public void mousePressed(MouseEvent me) {
If (me.getX( ) >= x1 && me.getX( ) <= x2 && me.getY( ) >= y1 && me.getY( ) <= y2)
Inside = True;
Else
Inside = false;
}
C) public void mouseReleased(MouseEvent me) {
If (me.getX( ) >= x1 && me.getX( ) <= x2 && me.getY( ) >= y1 && me.getY( ) <= y2)
Inside = True;
Else
Inside = false;
}
D) public void mouseEntered(MouseEvent me) {
If (me.getX( ) >= x1 && me.getX( ) <= x2 && me.getY( ) >= y1 && me.getY( ) <= y2)
Inside = True;
Else
Inside = false;
}
E) Requires both of the following methods: public void mouseEntered(MouseEvent me)
{
Inside = True;
}
Public void mouseExited(MouseEvent me)
{
Inside = false;
}
Correct Answer:
Verified
Q33: For the next questions, consider the following
Q34: For the questions below, assume that Student,
Q35: JApplet is an extension of the Applet
Q36: In order to implement the MouseListener interface,
Q37: A mouse event is a(n)
A) listener
B) object
C)
Q39: What is the advantage of using an
Q40: Clicking the mouse button generates three mouse
Q41: Regarding the Software Failure: Mid-air collisions were
Q42: Although classes can be inherited from one-another,
Q43: An Applet implements MouseMotionListener. Write the mouseMoved
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents