imagetestappletwithupdateandthread.java
来自「awt图形界面的生成」· Java 代码 · 共 47 行
JAVA
47 行
import java.net.URL;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
public class ImageTestAppletWithUpdateAndThread extends Applet {
private Image im;
public void init() {
URL codebase = getCodeBase();
System.out.println(codebase);
im = getImage(codebase, "saint.gif");
showImageSize();
SomeOtherThread sot = new SomeOtherThread();
sot.start();
}
public void paint(Graphics g) {
g.drawImage(im,0,0,this);
}
public boolean imageUpdate(Image image, int flags,
int x, int y, int w, int h)
{
System.out.println("imageUpdate(): x=" + x +
",y=" + y + " w=" + w + ",h=" + h);
if((flags & ALLBITS) != 0)
repaint();
return true;
}
private void showImageSize() {
System.out.print ("Image width=" + im.getWidth(this));
System.out.println(" height=" + im.getHeight(this));
}
}
class SomeOtherThread extends Thread {
public void run() {
while(true) {
System.out.println(
"s o m e o t h e r t h r e a d");
try { Thread.currentThread().sleep(500); }
catch (InterruptedException e) { }
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?