This is in JAVA/Swing
MouseEventLab
Write a GUI application that lets the user draw rectangles by pressing the mouse button and dragging the mouse before releasing it somewhere else inside the window. For example, if the first mouse click is the upper-left corner of the rectangle, the position that the mouse is released is the lower-right corner of the rectangle.
Note that you need to call repaint() when the mouse is released, in order for the paintComponent method to be called.