Using DrJava write a GUI that contains the following fields. Please comment code
ID: 3682792 • Letter: U
Question
Using DrJava write a GUI that contains the following fields. Please comment code.
a. MousePressed – Changes the fields fill color when the mouse button is down
b. MouseClicked – Changes the fields fill color when the mouse is clicked
c. MouseReleased – Changes the fields fill color when the mouse button is released
d. MouseEntered – Changes the fields fill color when the mouse comes into the drawing area
e. MouseExited – Changes the fields fill color when the mouse exits from the drawing area
f. MouseDragged – Changes the fields fill color when the mouse is dragged (left button down + mouse movement)
g. MouseXPos – Contains the mouse’s X coordinate position
h. MouseYPos – Contains the mouse’s Y coordinate position
Explanation / Answer
public void mousePressed(MouseEvent evt) {
// When user presses the mouse, tell the system to
// call the applet's paint() method.
repaint();
}
// The following empty routines are required by the
// MouseListener interface:
public void mousePressed(MouseEvent evt) { }
public void mouseExited(MouseEvent evt) { }
public void mouseClicked(MouseEvent evt) { }
public void mouseReleased(MouseEvent evt) { }
public void mouseDragged(MouseEvent evt) { }
public void mouseEntered(MouseEvent evt) { }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.