Next: 3 イベント処理
Up: 2 Interactive appletを作る
Previous: 2.1 サイズの取得 getSize()
<html>
<body>
<center>
<applet code="Param"
Width="300" Height="100">
<param name="message"
value="HTMLからパラメータが取得する");
</applet>
</center>
</body>
</html>
// Param.java
import java.applet.*;
import java.awt.*;
public class Param extends Applet {
public void paint(Graphics g) {
String msg = getParameter("message");
g.drawString(msg, 30, 20);
}
}
<html>
<body>
<center>
<applet code="Param2"
Width="300" Height="200">
<param name="x" value="200">
<param name="y" value="100">
</applet>
</center>
</body>
</html>
import java.applet.*;
import java.awt.*;
public class Param2 extends Applet {
public void paint(Graphics g) {
String strX = getParameter("x");
String strY = getParameter("y");
int x = Integer.parseInt(strX);
int y = Integer.parseInt(strY);
g.drawLine(0, 0, x, y);
}
}
generated through LaTeX2HTML. M.Inaba 平成18年5月7日