如何把java小程序镶嵌到html里 急求高手解答 20
展开全部
1.新建Java工程名applet,类名为AppletLifeCycle,代码如下:
import java.awt.*;
import java.applet.*;
public class AppletLifeCycle extends Applet
{
String status="";
public void init()
{status +="Call init() ->";
}
public void start()
{status+="Call start()->";
}
public void stop()
{status+="Call stop()->";
}
public void destroy()
{status+="Call destory()->";
}
public void paint(Graphics g)
{g.drawString(status, 20, 40);
}
}
2.在工程applet文件夹下,bin目录下,新建AppletLifeCycle.class.html,代码如下:
<html>
<head><title>Applet and HTML</title></head>
<body>
<applet code="AppletLifeCycle.class"width=300 height=45> </applet>
</body>
</html>
3.将AppletLifeCycle.class.html拖到浏览器中即可
import java.awt.*;
import java.applet.*;
public class AppletLifeCycle extends Applet
{
String status="";
public void init()
{status +="Call init() ->";
}
public void start()
{status+="Call start()->";
}
public void stop()
{status+="Call stop()->";
}
public void destroy()
{status+="Call destory()->";
}
public void paint(Graphics g)
{g.drawString(status, 20, 40);
}
}
2.在工程applet文件夹下,bin目录下,新建AppletLifeCycle.class.html,代码如下:
<html>
<head><title>Applet and HTML</title></head>
<body>
<applet code="AppletLifeCycle.class"width=300 height=45> </applet>
</body>
</html>
3.将AppletLifeCycle.class.html拖到浏览器中即可
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询