当前位置: 技术问答>java相关
关于Applet, 一个十分让人不理解的问题!!!?
来源: 互联网 发布时间:2015-11-15
本文导语: Code 1: package myapplet; import java.awt.*; import java.awt.event.*; import java.applet.*; public class Applet1 extends Applet { private boolean isStandalone = false; Button button1=new Button("Click Me"); //请注意这一行 //Get a parameter v...
Code 1:
package myapplet;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Applet1 extends Applet {
private boolean isStandalone = false;
Button button1=new Button("Click Me"); //请注意这一行
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public Applet1() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
add(button1);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}
// applet1.htm
HTML Test Page
myapplet2.Applet1 will appear below in a Java enabled browser.
这一个在JB7里run 没有错误
在IE中打开applet1.htm也正常
Code2:
package myapplet2;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
public class Applet1 extends Applet {
private boolean isStandalone = false;
private JButton jButton1 = new JButton("Click Me");//请注意这一行
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public Applet1() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
//jButton1.setText("jButton1");
this.add(jButton1, null);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}
//applet1.htm
HTML Test Page
myapplet2.Applet1 will appear below in a Java enabled browser.
这一个在JB7中能正常通过
但在IE中browse applet1.htm则发现报 “load:myapplet2.Applet1 can't be instantiated”这样的错误
各位高手能指点一下吗??
package myapplet;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Applet1 extends Applet {
private boolean isStandalone = false;
Button button1=new Button("Click Me"); //请注意这一行
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public Applet1() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
add(button1);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}
// applet1.htm
HTML Test Page
myapplet2.Applet1 will appear below in a Java enabled browser.
这一个在JB7里run 没有错误
在IE中打开applet1.htm也正常
Code2:
package myapplet2;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
public class Applet1 extends Applet {
private boolean isStandalone = false;
private JButton jButton1 = new JButton("Click Me");//请注意这一行
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public Applet1() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
//jButton1.setText("jButton1");
this.add(jButton1, null);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}
//applet1.htm
HTML Test Page
myapplet2.Applet1 will appear below in a Java enabled browser.
这一个在JB7中能正常通过
但在IE中browse applet1.htm则发现报 “load:myapplet2.Applet1 can't be instantiated”这样的错误
各位高手能指点一下吗??
|
兄弟,都是正常的,没有你说的错误!
你再看看吧
你再看看吧
|
ie的jre一般都是不支持swing的 你需要下载新的jre
|
个人认为applet最好不要用到swing 你知道客户端的ie是什么
|
这个是你的第二个用了swing,要么你把你用到的jar也加入html的applet标签里。如:archive= "dt.jar",或者去下个新版本的支持swing的jre。jre的版本你要去你的系统里看,别人怎么知道。