?? firstanimation.java
字號(hào):
// 程序:基本動(dòng)畫(huà)
// 范例文件:FirstAnimation.java
import java.awt.*;
import java.net.*;
import java.applet.*;
public class FirstAnimation extends Applet
{
URL ErrorHTML;
int currentImage;
Image Animation[];
MediaTracker MT;
public void init()
{
currentImage = 0;
Animation = new Image[8];
MT = new MediaTracker(this);
for(int i=0;i<8;i++)
{
Animation[i]
= getImage(getDocumentBase(),"Images/Freedom" + (i+1) + ".gif");
MT.addImage(Animation[i],0);
}
try
{
showStatus("圖像載入中...");
MT.waitForAll();
}
catch(InterruptedException E)
{
try
{
ErrorHTML = new URL(getCodeBase().toString() + "ErrorHTML.html");
}
catch(MalformedURLException ME){ }
getAppletContext().showDocument(ErrorHTML);
}
}
public void paint(Graphics g)
{
g.drawImage(Animation[currentImage],50,10,250,250,this);
try
{
Thread.sleep(125);
}
catch(InterruptedException E)
{
try
{
ErrorHTML = new URL(getCodeBase().toString() + "ErrorHTML.html");
}
catch(MalformedURLException ME){ }
getAppletContext().showDocument(ErrorHTML);
}
if(currentImage == 7)
currentImage = 0;
else
currentImage = currentImage + 1;
repaint();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -