Redraw a rectangle

Report a typo

Complete the code below so that it redraws the rectangle with the updated coordinates

@Override
public void mouseDragged(MouseEvent e) {
    rectX = e.getX();
    rectY = e.getY();
    //Missing line to draw the rectangle goes here
}
    
public void paint(Graphics g) {
    super.paint(g);
    g.drawRect(rectX, rectY, 50, 50);
}
Enter a short text
___

Create a free account to access the full topic