服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

利用applet标签载入applet


  下面是applet.jsp代码,主要说明了<applet>的用法

<%@ page contenttype="text/html; charset=gb2312"%>
<%@ page language="java" %>
<html>
<head>
<title>利用<applet>载入applet</title>
</head>
<body>
<center>
<font size = 5 color = blue>利用&ltapplet&gt载入applet</font>
</center>
<br>
<hr>
<br>
<center>
<!-- 载入applet -->
<applet code="helloworld.class" height="50" width="320" >
<param name="name" value="applet demo"> 
</applet>
</center>
<br>
</body>
</html>




其中helloworld.class是helloworld.java编译以后的文件,helloworld.java代码如下:


import java.applet.applet;
import java.awt.graphics;
public class helloworld extends applet
{
    string name;
    public void init()
    {
     name = getparameter("name");
    }
    public void paint(graphics g)
    {
        g.drawstring(" this is " + name + "!", 60, 25);
    }
}

扫描关注微信公众号