我通过一个JSP页面调用APPLET,在浏览JSP时该现实APPLET的地方却没有图出现啊,为什么?
APPLET代码为:
package four;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.JPanel;
import java.awt.Rectangle;
import javax.swing.JSplitPane;
import com.esri.mo2.ui.bean.Map;
import com.esri.mo2.ui.bean.Layer;
import com.esri.mo2.ui.bean.*;
import javax.swing.JToolBar;
import javax.swing.JButton;
import javax.swing.*;
public class Applet1 extends Applet {
boolean isStandalone = false;
BorderLayout borderLayout1 = new BorderLayout();
CardLayout cardLayout1 = new CardLayout();
JSplitPane jSplitPane1 = new JSplitPane();
Map map1 = new Map();
Layer layer1 = new Layer();
JToolBar jToolBar1 = new JToolBar();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
JButton jButton7 = new JButton();
JButton jButton8 = new JButton();
//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 {
this.setLayout(cardLayout1);
layer1.setDataset(
"com.esri.mo2.src.file.FileSystemConnection!E:/毕设/图/学校.shp!");
layer1.setBounds(new Rectangle(145, 92, 32, 32));
jToolBar1.setOrientation(JToolBar.VERTICAL);
jButton1.setToolTipText("放大");
jButton1.setText("jButton1");
jButton2.setToolTipText("缩小");
jButton2.setText("jButton2");
jButton3.setToolTipText("全景显示");
jButton3.setText("jButton3");
jButton4.setToolTipText("移动");
jButton4.setText("jButton4");
jButton5.setToolTipText("画框查询");
jButton5.setText("jButton5");
jButton6.setToolTipText("地图标注");
jButton6.setText("jButton6");
jButton7.setToolTipText("鹰眼地图");
jButton7.setText("jButton7");
jButton8.setToolTipText("地图测量");
jButton8.setText("jButton8");
this.add(jSplitPane1, "jSplitPane1");
jSplitPane1.add(map1, JSplitPane.RIGHT);
map1.add(layer1);
jSplitPane1.add(jToolBar1, JSplitPane.LEFT);
jToolBar1.add(jButton1);
jToolBar1.add(jButton2);
jToolBar1.add(jButton3);
jToolBar1.add(jButton4);
jToolBar1.add(jButton5);
jToolBar1.add(jButton6);
jToolBar1.add(jButton7);
jToolBar1.add(jButton8);
jSplitPane1.setDividerLocation(80);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
//Main method
public static void main(String[] args) {
Applet1 applet = new Applet1();
applet.isStandalone = true;
Frame frame;
frame = new Frame();
frame.setTitle("Applet Frame");
frame.add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400, 320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2,
(d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
}
JSP代码为:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page errorPage="jsp1_error.jsp" %>
<html>
<head>
<title>
jsp1
</title>
</head>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
</h1>
<form method="post" action="jsp1.jsp">
<br><br>
<applet
codebase = "."
code = "four.Applet1.class"
name = "TestApplet"
width = "600"
height = "600"
hspace = "0"
vspace = "0"
align = "middle"
>
</applet>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
----------------解决方案--------------------------------------------------------