📄 sw.java
字号:
import java.applet.Applet;
import java.awt.*;
import java.awt.Font;
public class sw extends Applet implements Runnable
{
int x=20,y=30,w=160,h=200;
int x1=40,y1=90,w1=50,h1=20;
int x2=55,y2=y1,w2=20,h2=h1;
int x3=110,y3=90,w3=50,h3=20;
int x4=125,y4=y3,w4=20,h4=h3;
int y5=170,h5=10;
int x6[]={100,90,110,100};
int y6[]={120,145,145,120};
String sh1="";
Font font1=new Font("TimesRoman",Font.BOLD,24);
int m=1,n=20;
Thread th1,th2,th3;
public void start()
{
if(th1==null&&th2==null)
{
th1=new Thread(this);
th1.start();
th2=new Thread(this);
th2.start();
th3=new Thread(this);
th3.start();
}
}
public void run()
{
Thread current=Thread.currentThread();
while(th1==current)
{ if(((m%2) !=0)&&m<=9)
{if(y1==100){m=m+1;}
y1=y1+2;h1=h1-4;
h2=h1;y2=y1;
y3=y3+2;h3=h3-4;
h4=h3;y4=y3;
repaint();
try{
th1.sleep(0);}
catch(InterruptedException e){}
}
if(((m%2)==0)&&m<=10)
{if(y1==90){m=m+1;}
y1=y1-2;h1=h1+4;
h2=h1;y2=y1;
y3=y3-2;h3=h3+4;
h4=h3;y4=y3;
repaint();
try{
th1.sleep(0);}
catch(InterruptedException e){}
}
if(m>10)
{ try{
th1.sleep(15000);}
catch(InterruptedException e){}}
}
while(th2==current)
{
if(((m%2) !=0)&&m>10&&m<=15)
{if(y5==175){m=m+1;}
y5=y5+1;h5=h5-2;
sh1="热 烈 欢 迎 您!";
repaint();
try{
th2.sleep(30);}
catch(InterruptedException e){}
}
if(((m%2)==0)&&m>11&&m<=16)
{if(y5==170){m=m+1;}
sh1="热 烈 欢 迎 您!";
y5=y5-1;h5=h5+2;
if(m>16){n=1;sh1="";y3=100;h3=0;}
repaint();
try{
th2.sleep(30);}
catch(InterruptedException e){}
}
if(m>16)
{ try{
th1.sleep(15000);}
catch(InterruptedException e){}}
}
while(th3==current)
{
if(n==1)
{if(y1==100){n=2;}
y1=y1+2;h1=h1-4;
h2=h1;y2=y1;
y3=y3-2;h3=h3+4;
h4=h3;y4=y3;
sh1="眨眨眼 示意您!";
repaint();
try{
th3.sleep(30);}
catch(InterruptedException e){}
}
if(n==2)
{if(y1==90){n=1;}
y1=y1-2;h1=h1+4;
h2=h1;y2=y1;
y3=y3+2;h3=h3-4;
h4=h3;y4=y3;
sh1="眨眨眼 示意您!";
repaint();
try{
th3.sleep(30);}
catch(InterruptedException e){}
}
}
}
public void paint(Graphics g)
{g.setColor(new Color(180,180,0));
g.fillOval(x,y,w,h);
g.setColor(Color.red);
g.fillPolygon(x6,y6,4);
g.setColor(Color.white);
g.fillOval(x1,y1,w1,h1);
g.setColor(Color.black);
g.fillOval(x2,y2,w2,h2);
g.setColor(Color.white);
g.fillOval(x3,y3,w3,h3);
g.setColor(Color.black);
g.fillOval(x4,y4,w4,h4);
g.setColor(new Color(100,220,0));
g.fillRoundRect(25,10,150,60,30,30);
g.setColor(Color.red);
g.fillOval(80,y5,40,h5);
g.setFont(font1);
g.drawString(sh1,20,250);
g.setColor(Color.red);
g.setFont(font1);
g.drawString(" Swan ",60,50);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -