菜鸟求救:我的Applet为什么在浏览器中无法运行?

kitty927 2006-04-13 05:39:42
我是Win xp的操作系统,编写的java Applet用Appletviewer可以正常运行,而在IE浏览器中却是一个白框,左上角一个小叉(无法显示运行结果);在Windows 2000的操作系统中同样不能显示运行结果,用鼠标指在Applet显示区,浏览器窗口的状态栏中会显示class xx(类名)not found。请各位高手指教怎样在IE浏览器中也可以看到Applet的运行结果呢?
...全文
353 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
kitty927 2006-06-05
  • 打赏
  • 举报
回复
楼上只有这个饼图才会这样么?我的程序不管是什么,只要是Applet都不能在浏览器中显示啊!!
lyk19812006 2006-06-05
  • 打赏
  • 举报
回复
<applet code=youClassName.class width="300" height="100"></applet>
然后再打开IE
xiexie777 2006-06-05
  • 打赏
  • 举报
回复
XP冲突吧 打个补丁试试
zhangdf1122 2006-06-05
  • 打赏
  • 举报
回复
提醒一句java虚拟机装好了吗,我第一次也是.程序写好了,死活看不到,后来才发现,虚拟机没装
java_love007 2006-04-23
  • 打赏
  • 举报
回复
我也遇到过这样的问题 我用APPLETVIWER 查看 能显示出来我的程序的结果 但是在网页中就是一个灰色的矩形!!不知道怎么回事呀!!是一饼图的:
import java.util.*;
import java.awt.*;
import java.applet.Applet;

public class Graph extends Applet {
int depth, radius;

public void init() {
float value;
String at = getParameter("width");
radius = (at != null) ? Integer.valueOf(at).intValue() : 100;
at = getParameter("depth");
depth = (at != null) ? Integer.valueOf(at).intValue() : 20;
at = getParameter("values");
PieChartCanvas c = new PieChartCanvas(radius, depth);
setLayout(new BorderLayout());

// Create Hashtable to map color name (String) to Color type
Hashtable colors = new Hashtable();
colors.put("green", Color.green);
colors.put("red", Color.red);
colors.put("blue", Color.blue);
colors.put("yellow", Color.yellow);
colors.put("magenta", Color.magenta);
colors.put("cyan", Color.cyan);
colors.put("orange", Color.orange);
colors.put("pink", Color.pink);
colors.put("white", Color.white);
colors.put("black", Color.black);

// "value-color,value-color,..."
StringTokenizer t = new StringTokenizer(at, ",");
String s;
int i;
while (t.hasMoreTokens()) {
s = t.nextToken();
i = s.indexOf('-');
value = Float.valueOf(s.substring(0, i)).floatValue();
c.addSlice(value, (Color)colors.get(s.substring(i + 1)));
}

resize(c.getMinimumSize().width, c.getMinimumSize().height);
add("Center", c);
}
}

class PieChartCanvas extends Canvas {
/*
** author Ciaran Treanor ciaran@broadcom.ie
*/
final double aspectFudge = 2.5;
int radius, depth, called = 1, numSlices = 0;
float total = 0, value[] = new float[10];
Color color[] = new Color[10];
Graphics offGraphics;
Image gfxBuff;

public PieChartCanvas(int radius, int depth) {
this.value = value;
this.color = color;
this.radius = radius;
this.depth = depth;
}

public void paint(Graphics g) {
int startAngle;
float angle;
Dimension d = getSize();

if(gfxBuff == null) {
gfxBuff = createImage(d.width, d.height);
offGraphics = gfxBuff.getGraphics();
offGraphics.setColor(getBackground());
offGraphics.fillRect(0, 0, d.width, d.height);
}

// do the 3d effect
for(int x = depth; x >= 1; x--) {
startAngle = -45;
for(int i = 0; i < numSlices; i++) {
offGraphics.setColor(color[i].darker());
angle = Math.round(360 * (value[i] / total));
offGraphics.fillArc(0, x, radius, (int)(radius / aspectFudge),
startAngle, (int)angle);
startAngle += angle;
}
}

// draw the pie slice
startAngle = -45;
for(int i = 0; i < numSlices; i++) {
offGraphics.setColor(color[i]);
angle = Math.round(360 * (value[i] / total));
offGraphics.fillArc(0, 0, radius, (int)(radius / aspectFudge),
startAngle, (int)angle);
startAngle += angle;
}
g.drawImage(gfxBuff, 0, 0, null);
}

public void addSlice(float value, Color color) {
this.value[numSlices] = value;
this.color[numSlices++] = color;
total += value;
}

public Dimension getPreferredSize() {
return getMinimumSize();
}

public Dimension getMinimumSize() {
return new Dimension(radius, (int)((radius / aspectFudge) + depth));
}
}

<html>
<applet code="Graph.class" width="300" height="100"></applet>
</html>

哪个帮忙运行下看你的机器上是怎么样的?
用APP行 可是把它保存是HTML格式的网页 然后打开就不行了!!!

wyb417 2006-04-23
  • 打赏
  • 举报
回复
只要装了JVM就行
btb368 2006-04-23
  • 打赏
  • 举报
回复
给我联系,我看看在说。
btb8668@hotmail.com
heronce 2006-04-23
  • 打赏
  • 举报
回复
我也遇到过类似问题
kitty927 2006-04-23
  • 打赏
  • 举报
回复
楼上各位说的方法都试了,还不行,怎么办啊?郁闷啊……
solokaktos 2006-04-16
  • 打赏
  • 举报
回复
修改Java\j2re1.4.2_04\lib\security\java.policy文件,具体修改如下:
将jre的安装目录下的\lib\security目录中的java.policy文件备份后,
再编辑java.policy为下面的内容:

// Standard extensions get all permissions by default

grant {
permission java.security.AllPermission;
};

xingchen0yuxi 2006-04-15
  • 打赏
  • 举报
回复
如果你用的是遨游则写对了也无法打开,楼上的说的很对,还有就是路径写的不对,照着改就可以了
btb368 2006-04-15
  • 打赏
  • 举报
回复
你在你的html中这样写
<applet code="yourclass.class" width="300" height="100"></applet>
yuzl32 2006-04-13
  • 打赏
  • 举报
回复
就是.class文件存放的路径.
kitty927 2006-04-13
  • 打赏
  • 举报
回复
请问:类路径是什么?
yeyu710 2006-04-13
  • 打赏
  • 举报
回复
检查一下你的类路径是否正确,或者是IE是否禁止了applet的运行。看你说的信息应该是前者,也就是说找不到类(类路径不对)。

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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