But for Free-Hand drawing, we should not wait till mouse release. We should draw while the mouse is dragged. This means we need to arrange the points P1 and P2 on each reported drag event. In the first part of the below picture, the Red Cross line shows the MouseEvent which AWT reports to the listener. We can still use the drawLine API and connect the currently reported point with the previous one. The net effect is a smooth curve even-though what we draw is a straight line in small chunks. Note, AWT reports the drag events so quickly and hence user will not see the straight inter-connected lines.
Tag Archive for ‘mouseDragged’
In 80s, usually mouse came with only two buttons. One is for left click and other one is for right click. Now as days mouse comes with three buttons and a wheel in the middle. The wheel allows scrolling the contents, and also it allows click. Below is the picture of the modern days mouse.