Please visit our sponsor

FallingText

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

public class fallingtext extends Applet implements Runnable {

public Thread animationthread = null;
public String message;

public void init()
{
    message="Falling text is a cool effect!";
}

public void start()
{
    if (animationthread == null)
    {
         animationthread = new Thread(this,"animationthread");
         animationthread.start();
    }
}

public void stop()
{
    if ((animationthread != null) && animationthread.isAlive())
        animationthread.stop();
    animationthread = null;
}

public void run()
{
    int L=message.length();

    //Create a string with a blankspace for the animation.
    String blankspace="                                 ";
    blankspace=blankspace+blankspace+blankspace;

    //Set the variable "mL" to the blankspace's length.
    int mL=blankspace.length();

    //The first loop will count up to the message's
    //length minus one.
    for (int i=0; i<L-1; i++)
{ //The second loop will count up to the blankspace's
//string length with 8 step's at the time in order
//to increase speed. for (int i=0; imL; j+=8) { //Show an increasing part of the message //with a decreasing part of the blankspace //and the last letter in the message string. showStatus(message.substring(0,i) +blankspace.substring(j) +message.substring(i,i+1)); try {Thread.sleep(50);} catch(InterruptedException e) {} } } //The last loop will see to that the //message is not overwritten by other status //messages. while(true) { showStatus(message); try {Thread.sleep(50);} catch(InterruptedException e) {} } } }

 


  This is a Mandomartis site: Other Mandomartis sites are:
 

 

 

 

 

Copyright © 1999 Scandinavia Online AB and Mandomartis Software Company