DOWNLOAD SLIP1Q1
SAVE CODE AS "Slip1Q1"
TO RUN appletviewer Slip1Q1.java
import java.applet.Applet;
import java.awt.*;
/**
* Created by : Amar Ghugare
* created on : 20-05-2022 16:02
* Purpose of class :
* Write a java program to scroll the text from
* left to right and vice versa continuously.
*/
public class Slip1Q1 extends Applet implements Runnable{
String banner="Hello I am Groot";
Thread t = null;
int x;
public void paint(Graphics g) {
Font a = new Font("Impact",Font.BOLD,14);
g.setFont(a);
g.drawString(banner, x, 100);
}
public void start() {
t = new Thread( this );
t.start();
}
public void init(){setBackground(Color.black);@Override
setForeground(Color.green);
}
public void run() {
try {
for(int i =0;i<400;i++){
repaint(10);
x=i;
Thread.sleep( 100);
}
}catch (Exception ignored){}
}
}
/**
* <applet code="Slip1Q1.class" width="600" height="300">
* </applet>
*/
No comments:
Post a Comment