?? testapplet.java
字號:
import java.applet.*;
import java.awt.*;
public class TestApplet extends Applet implements Runnable
{
Thread thread1,thread2;
AudioClip m_audio;
Image[] m_Images = new Image[5];
int totalImages = 5;
int currentImage = 0;
String strname,strage,strsex,strnum,strphone;
int rectWidth,rectHeight;
public void init()
{
m_audio = getAudioClip(getCodeBase(),"sound/test.au");
for(int i=0;i<=totalImages-1;i++)
m_Images[i] = getImage(getDocumentBase(),"IMAGES/p"+i+".gif");
strname = getParameter("myname");
strage = getParameter("myage");
strsex = getParameter("mysex");
strnum = getParameter("mynum");
strphone= getParameter("myphone");
rectWidth = 100;
rectHeight = 50;
}
public void start()
{
if(thread1 ==null)
{
thread1 = new Thread(this,"t1");
thread1.start();
}
if(thread2 == null)
{
thread2 = new Thread(this,"t2");
thread2.start();
}
}
public void run()
{
String s = Thread.currentThread().getName();
System.out.println("--------"+s+"-----");
if(s.equals("t1"))
{
while(true)
{
m_audio.play();
try{
Thread.sleep(3000);
}
catch(InterruptedException e) {}
}
}
else if(s.equals("t2"))
{
while(true)
{
repaint();
try{
Thread.sleep(2000);
}
catch(InterruptedException e) {}
}
}
}
public void stop()
{
thread1 = null;
thread2 = null;
}
public void destroy()
{
}
public void paint(Graphics g)
{
Font f = new Font("仿宋_GB2312",0,20);
g.setFont(f);
g.setColor(Color.blue);
g.drawString(strname,10,20);
g.drawString(strage,10,40);
g.drawString(strsex,10,60);
g.drawString(strnum,10,80);
g.drawString(strphone,10,100);
for(int i=0;i<4;i++)
for(int j=0;j<=i;j++)
{
g.drawString("*",300+(i-j)*20,20+i*20);
g.drawString("*",300-(i-j)*20,20+i*20);
}
g.drawImage(m_Images[currentImage],200,150,this);
currentImage = ++currentImage % totalImages;
g.drawRect(10,120,rectWidth,rectHeight);
g.drawOval(10,120,rectWidth,rectHeight);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -