Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)

Tag Archive for ‘repaint’

FreeHand Drawing: AWT Drawing – Part 4

FreeHand Drawing: Chaining of P1 and P2 between Reported Drag Events

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.

Continue Reading →