F
firesword
Unregistered / Unconfirmed
GUEST, unregistred user!
我安装了j2sdk1.4.0-beta3后,发现里面的demo都不能用,就是用jdk1.4编译好的applet不能显示出来,比如下面这个例子
import java.awt.*;
import java.applet.*;
public class DrawText extends Applet {
String s;
Button btnFirst=new Button("first");
Button btnSecond=new Button("second");
TextField txtfldFirst=new TextField("zhuzhu",20);
int inits=0;
int starts=0;
int stops=0;
int paints=0;
public void start(){starts++;}
public void stop(){stops++;}
public void init(){
inits++;
add(btnFirst);
add(btnSecond);
add(txtfldFirst);
}
public void paint(Graphics g){
paints++;
g.drawString("asdlfkjalsdf",10,110);
g.draw3DRect(0,100,100,20,true);
s="inits="+inits+" starts="+starts+" stops="+stops+" paints="+paints;
g.drawString(s,10,130);
}
public boolean action(Event evt,Object arg){
if (evt.target.equals(btnFirst)){
FileDialog d=new FileDialog(null,"测试");
d.show();
}
else
{
return super.action(evt,arg);
}
return true;
}
}
//html文件为
<html>
<head>
<title>test using applets(1.1)</title>
</head>
<body>
<applet code="DrawText.class" width=300 height=200>
</applet>
</body>
</html>
但是用jdk1.3编译的applet可以正确的显示.
import java.awt.*;
import java.applet.*;
public class DrawText extends Applet {
String s;
Button btnFirst=new Button("first");
Button btnSecond=new Button("second");
TextField txtfldFirst=new TextField("zhuzhu",20);
int inits=0;
int starts=0;
int stops=0;
int paints=0;
public void start(){starts++;}
public void stop(){stops++;}
public void init(){
inits++;
add(btnFirst);
add(btnSecond);
add(txtfldFirst);
}
public void paint(Graphics g){
paints++;
g.drawString("asdlfkjalsdf",10,110);
g.draw3DRect(0,100,100,20,true);
s="inits="+inits+" starts="+starts+" stops="+stops+" paints="+paints;
g.drawString(s,10,130);
}
public boolean action(Event evt,Object arg){
if (evt.target.equals(btnFirst)){
FileDialog d=new FileDialog(null,"测试");
d.show();
}
else
{
return super.action(evt,arg);
}
return true;
}
}
//html文件为
<html>
<head>
<title>test using applets(1.1)</title>
</head>
<body>
<applet code="DrawText.class" width=300 height=200>
</applet>
</body>
</html>
但是用jdk1.3编译的applet可以正确的显示.