A simple applet that displays a banner.
The text is placed inside variable msg
import java.awt.*;
import java.applet.*;
/*
<applet code="banner" width = 300 height = 50>
</applet>
*/
public class banner extends Applet implements Runnable{
String msg = " Java";
Thread t = null;
int state;
boolean stopFlag;
public void init(){
setBackground(Color.cyan);
setForeground(Color.red);
}
public void start(){
t = new Thread(this);
stopFlag = false;
t.start();
}
public void run(){
char ch;
for( ; ; ){
try {
repaint();
Thread.sleep(250);
ch = msg.charAt(0);
int j = msg.length();
msg = msg.substring(1, j);
msg += ch;
if(stopFlag)
break;
}
catch(InterruptedException e){}
}
}
public void stop(){
stopFlag = true;
t = null;
}
public void paint(Graphics g){
g.drawString(msg, 50,30);
}
}
Compile as javac banner.java
Run as appletviewer banner.java
Tags:banner in java,java banner,applet,applet in java,java banner applet
Subscribe to:
Post Comments
(
Atom
)
1F4CC6E9C1
ReplyDeleteBeğeni Satın Al
Yabancı Takipçi
iG Takipçi
ReplyDeleteWhen choosing the right material for your custom apparel, it’s essential to consider the quality of the transfer. The dtf transfer film offers excellent durability and vibrant colors, making it a popular choice among clothing manufacturers. This film ensures that designs remain intact even after multiple washes, providing long-lasting results. For those interested in high-quality transfers, exploring different options like the dtf transfer film can make a significant difference in the final product.