Monday, January 20, 2014

Java Program to illustrate Flash News

with 0 Comment
import java.applet.*;
import java.awt.*;
/*<applet code="Flashnews" width=500 height=500>
</applet>*/

public class Flashnews extends Applet implements Runnable
{
Thread t;
int x,y;
int i;
String msg="Welcome to Applet";
public void init()
{
setBackground(Color.white);
setForeground(Color.black);
}
public void start()
{
t=new Thread(this);
t.start();
}
public void run()
{
try
{
for(i=0;i<=400;i=i+10)
{
repaint();
Thread.sleep(500);
if(i==390)
i=0;
}
}
catch(InterruptedException ie)
{
System.out.println("Exception="+ie);
}
}
public void paint(Graphics g)
{
g.drawString(msg,i,390);
}
}

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive