日期:2014-05-17 浏览次数:20754 次
import javax.swing.*; import java.awt.*; public class ParamDemo extends JApplet { private String s; private int x; private int y; private int mySize; private String fontName; Font fnt; public void init() { s = getParameter("string"); x = Integer.parseInt(getParameter("xp")); y = Integer.parseInt(getParameter("yp")); fontName = getParameter("font"); mySize = Integer.parseInt(getParameter("size")); fnt = new Font(fontName, Font.BOLD, mySize); } public void paint(Graphics g) { g.setFont(fnt); g.drawString(s, x, y); } }
<html> <head> <title>Applet与HTML之间的参数传递</title> </head> <body> <applet code="ParamDemo.class" width=300 height=200 VIEWASTEXT> <param name=font value="隶书"> <param name=size value="20"> <param name=string value="我是从HTML网页中来的!"> <param name=xp value="20"> <param name=yp value="50"> </applet> </body> </html>