applet带外部参数问题

lcrain428 lcrain428 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
程序代码如下:

//HelloWorld.java
import java.awt.*;
import java.applet.*;

public class HelloWorld extends Applet{
private String title;
private int size;
private int color;
public void init(){
title="Hello World!";
size=Integer.parseInt(getParameter("size"));
color=Integer.parseInt(getParameter("color"));
}
public void paint(Graphics g){
Color c=new Color(color);
Font f=new Font("",1,size);
g.getColor(c);
g.getFont(f);
g.drawString("Hello World!", 30, 30);
}
}

//HelloWorld.html
<html>
<applet code="HelloWorld.class" width=400 height=150 codebase="./bin">
<param name=size value=40>
<param name=color value=008800>
</applet>
</html>

用eclipse运行就失败。
原因我觉得是这样的:HelloWorld.java先调用外部参数,生成HelloWorld.class,但是此时没有外部参数,
导致init()失败,问怎么修改,还是我java配置不当?其他的java程序都能运行起来
...全文
评论 7
收藏 已收藏
分享
返回顶部
lcrain428
Eclipse 58,439 成员 49,457 内容