Creating a Simple Paint Program in Java
Introduction
In this tutorial, a simple Paint program is created, which enables us to draw anything to screen. It's a basic program to understand the logic behind creating a paint program. Here main concept is implementing MouseMotionListener which handles mouse events. Whenever mouse is dragged a mouse event is sent to Java which finds the event listener in the program in order to take any action.
We need to implement only mouseDragged() of many functions of MouseMotionListener class to draw to the Panel.