In this article we shall be explaining the code to display moving text in Java. To print the string in the window we will use the drawString() method from java.awt package. The drawString method takes three arguments :
drawString(string, x, y)
- string : This parameter takes the string to be displayed.
- x : This parameters takes the x co-ordinates where the string will be displayedon the screen.
- y : This parameter takes the y co-ordinates where the string will be displayed
on the screen.
We will be printing the string at (x, y) co-ordinates and then update the x co-ordinate and then repaint the screen again.
Note: The above function are a part of java.awt package and belongs to java.awt.Graphics class. Also, these codes might not run in an online compiler please use an offline compiler. The x and y coordinates can be changed by the programmer according to their need.
- Draw a Smiley in Java Applet
- Java Applet | Digital Stopwatch
- Draw a Chessboard in Java Applet
- Draw a ellipse and a rectangle in Java Applet
- Java Applet | How to display a Digital Clock
- Draw an Olympic Symbol in Java Applet
- Java Applet | How to display an Analog Clock
- Java Applet | Draw a line using drawLine() method
- Java Applet | Implementing Flood Fill algorithm
- Java Swing | Create a simple text editor
- Hamming code Implementation in Java
- Hackathon - Think, Code, Create
- DFA in LEX code which accepts even number of zeros and even number of ones
- Java lang.Long.builtcount() method in Java with Examples
- Java.util.BitSet.clear() in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.