Applet.htlm 文件怎样写,写在那里?

iceandsnow 2003-06-11 01:39:44
我建立了Applet1.java 和 Applet2.java 两个小应用程序,他们在JBuild8下,用菜单中的run ->run Applet1.html use Applet1 编译通过了 ,但我自己建立一个Applet.html文件(用写字板,应为jBuild8中没有找到怎样建立html文件),总是显示没有找到class Applet1 没有找到,为什么?我的Applet.html文件怎样改,应放在那个目录下。
Apple1的内容如下,在jBulid 内部已经编译成功,但在doc下用java Applet1.java 进行编译出现 pageage com.borland.jbcl.layout.* 没有发现。为什么?



package app;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import com.borland.jbcl.layout.*;

public class Applet1 extends Applet {
private boolean isStandalone = false;
XYLayout xYLayout1 = new XYLayout();
Label label1 = new Label();
TextArea textArea1 = new TextArea();
Label label2 = new Label();
Button button1 = new Button();
Button button2 = new Button();
Button button3 = new Button();
AppletContext ac=null;
Applet Applet=null;
//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 {
label1.setText("从右面的Applet接收到的数据:");
this.setLayout(xYLayout1);
textArea1.setText("textArea1");
label2.setText("控制 右面 Applet的背景颜色");
xYLayout1.setWidth(400);
xYLayout1.setHeight(300);
button1.setLabel("红色");
button1.addActionListener(new Applet1_button1_actionAdapter(this));
button2.setLabel("白色");
button2.addActionListener(new Applet1_button2_actionAdapter(this));
button3.setLabel("恢复");
button3.addActionListener(new Applet1_button3_actionAdapter(this));
this.setBackground(SystemColor.control);
this.add(label1, new XYConstraints(31, 12, 189, 24));
this.add(textArea1, new XYConstraints(31, 42, 202, 173));
this.add(button2, new XYConstraints(104, 256, 74, 26));
this.add(button3, new XYConstraints(186, 256, 73, -1));
this.add(button1, new XYConstraints(17, 256, 77, -1));
this.add(label2, new XYConstraints(30, 222, 162, 28));
ac=this.getAppletContext() ;
Applet=ac.getApplet("Applet2") ;
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}

void button1_actionPerformed(ActionEvent e) {

}

void button2_actionPerformed(ActionEvent e) {
Applet.setBackground(Color.white ) ;
}

void button3_actionPerformed(ActionEvent e) {
Applet.setBackground(new Color(192,192,192));
}

}

class Applet1_button1_actionAdapter implements java.awt.event.ActionListener {
Applet1 adaptee;

Applet1_button1_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button1_actionPerformed(e);
}
}

class Applet1_button2_actionAdapter implements java.awt.event.ActionListener {
Applet1 adaptee;

Applet1_button2_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button2_actionPerformed(e);
}
}

class Applet1_button3_actionAdapter implements java.awt.event.ActionListener {
Applet1 adaptee;

Applet1_button3_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button3_actionPerformed(e);
}
}

Applet.html 文件的内容如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>
Applet 之间的通信
</title>
</head>
<body bgcolor="#ffffff">
<table width=100%>
<tr>
<td width=50%>第一个Applet</td>
<td width=50%>第二个Applet</td>
</tr>
<tr>
<td width=50%>
<APPLET
CODEBASE="."
CODE="app.Applet1.class"
NAME="Applet1"
WIDTH="380"
HEIGHT="250"
hspace="0"
vspace="0"
align="middle"
>
</APPLET>
</td>
<td width=50%>
<APPLET
CODEBASE="."
CODE="app.Applet2.class"
NAME="Applet2"
WIDTH="380"
HEIGHT="250"
hspace="0"
vspace="0"
aligh="middle"
>
</APPLET>
</td>
</tr>
</table>
</body>
</html>
...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
iceandsnow 2003-06-11
  • 打赏
  • 举报
回复
1、就是我写的Applet.html打开时显示load class Applet1 not found ,是不是我的Applet.html 文件的内容写错了,源程序如上(Applet1.java 和Applet.html)。

2、为什么我的Applet1.java 在jBulid8中可以编译,但在doc下出现 pageage com.borland.jbcl.layout.* 没有发现。为什么?
wswhp 2003-06-11
  • 打赏
  • 举报
回复
什么问题

51,408

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧