-
Notifications
You must be signed in to change notification settings - Fork 0
/
java_code.java
61 lines (54 loc) · 907 Bytes
/
java_code.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*<applet code="Appletfun" width="1000" height="1000">
<param name=str value="Java Applet">
</applet>*/
import java.awt.*;
import java.applet.*;
public class Appletfun extends Applet implements Runnable
{
Thread t;
String str="",temp="";
Boolean b=true;
int i=0;
Font f=new Font("Arial",40,40);
public void init()
{
t=new Thread(this);
}
public void start()
{
t.start();
}
public void paint(Graphics g)
{
g.setFont(f);
int k=40;
for(int j=0;j<=temp.length()-1;j++)
{
String ch=temp.charAt(j)+"";
if((j+1)%2==0)
{
g.setColor(Color.green);
}
else
{
g.setColor(Color.red);
}
g.drawString(ch,k,100);
k=k+40;
}
}
public void run()
{
str=getParameter("str");
for(i=0;i<=str.length()-1;i++)
{
temp+=str.charAt(i);
repaint();
try
{
t.sleep(1000);
}
catch(Exception e){}
}
}
}