C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » Java programs » Java applet programs

Java Applet program to display moving text or content

Here, we are going to write a java applet program that will display moving text (content) on the screen.
Submitted by Chandra Shekhar, on January 11, 2018

Given a message or a text, co-ordinates and the initial state this will help in moving the text using java applet program.

Applet program to display moving text in java

// This java program will move the text using applet.

package Applet;

import java.awt.*;
import java.applet.*;

public class MovingContent extends Applet implements Runnable 
	// enter message
	String msg = "Welcome to Includehelp.";
	Thread t = null;
	// initialize here.
	int state;
	boolean stopFlag;

	// Set colors and initialize text..
	public void init() 

	// Start the text....
	public void start() 
		t = new Thread(this);
		stopFlag = false;

	// Entry point which runs the text.
	public void run() 
		char ch;
		// Display text reapeated times.
		for( ; ; ) 
				ch = msg.charAt(0);
				msg = msg.substring(1, msg.length());
				msg += ch;
			catch(InterruptedException e) 

	// Pause the text.
	public void stop() 
		stopFlag = true;
		t = null;

	// Display the text.
	public void paint(Graphics g) 
		g.drawString(msg, 50, 30);


Moving text/content in java applet

You may also be interested in...

C/C++ Tips and Tricks...

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions