https://github.com/msh-trojan/java_21_animation_1
A simple program showing a simple animation of a circle going forward and backward.
https://github.com/msh-trojan/java_21_animation_1
animation gui-components java jframe thread
Last synced: about 2 months ago
JSON representation
A simple program showing a simple animation of a circle going forward and backward.
- Host: GitHub
- URL: https://github.com/msh-trojan/java_21_animation_1
- Owner: MSH-trojan
- Created: 2024-08-15T17:20:38.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-15T17:48:28.000Z (almost 2 years ago)
- Last Synced: 2025-06-06T09:05:22.512Z (about 1 year ago)
- Topics: animation, gui-components, java, jframe, thread
- Language: Java
- Homepage:
- Size: 82 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Java_21_Animation_1
This JFrame application is the programming behind many computer games.
In this application a red circle is moving (non-stop) between the top-left point (10,30) and the middle of the frame (100,130) (i.e. in both directions)
This program one creates a thread in which the position of the red circle is recalculated and the method repaint() is used to replace the old circle with the new one.
Each circle is displayed for 50 milliseconds.
Class Anim.java can be changed to have the red circle moving from the top right corner of the frame to the middle of the frame.
The code is the class Anim1.java which inside method paint() has:
g.fillOval(getWidth()-20-position, 20+position, 30, 30);
The top right corner has the coordinates:
(getWidth()-20, 20)
and x is decreased, while y is increased.