This tutorial will help you to understand the relation between ActionListener and Timer Class.
In this tutorial we will move rectangle using ActionListener and Timer Class.

There are simple easy steps to implement ActionListener

Step 1: Create new java application project.




Step 2:  Extends main class to JFrame and follow screen.


Step 3: Create new class Panel and extends it to JPanel and follow screen.




Step 4: Create new class Rectangle and follow screen.




Step 5: Add ActionListener, Timer and Rectangle in Panel Class as in Image.




Step 6: Add Panel in JFrame.



Step 7: Done!   Run your Project.

OUTPUT will be:




Keep Smiling Keep Coding :)
Watch Youtube Video for full explanation :)



Easy Steps to draw shapes and fill shapes with color in java :)

Step 1. Create new Java Application Project.



Step 2.  Extend your main class with JFrame. Follow image.


Step 3. Create new Java Class  "Panel" and extends it to JPanel. Follow image.


Step 4. Add Panel to JFrame.


Step 5. Run your project

OUTPUT:

.

Now create the visual image in your mind and draw it on screen with JAVA.



The more you CREATIVE, the more you INNOVATE JAVA :)

Keep Smiling, Keep Coding :)


Watch this tutorial on YOUTUBE :)