📄 applet1.java
字号:
import java.awt.*;
import java.applet.*;
import java.awt.image.*;
/**
* This class reads PARAM tags from its HTML host page and sets
* the color and label properties of the applet. Program execution
* begins with the init() method.
*/
public class Applet1 extends Applet
{
Image img;
boolean loaded;
public void init()
{
img=getImage(getDocumentBase(),"bg.jpg");
loaded=false;
}
public void paint(Graphics g){
System.out.println("in paint:image width"+img.getWidth(this));
System.out.println("in paint:image height"+img.getHeight(this));
///g.drawImage(img,20,20,this);
Handler handler=new Handler();
handler.applet=this;
g.drawImage(img,0,0,handler);
}
}
class Handler implements ImageObserver{
Applet applet;
public boolean imageUpdate(Image img,int info,int x,int y,int width,int height){
boolean first=true;
if ((info&WIDTH)==0)
System.out.println("image width not available,current width "+width);
else
System.out.println("image width available,current width "+width);
if ((info&ERROR)==0 && (info&ABORT)==0)
System.out.println("no error now");
else{
System.out.println("error occur and abort");
return false;
}
if ((info&ALLBITS)==0){
System.out.println("image are loading");
return true;
}else{
System.out.println("image has been loaded");
applet.repaint();
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -