如何在java applet程序中设置从html文件作为参数传递到矩形的颜色
一个java小程序,用于显示一个矩形,其中指定的坐标和颜色作为参数从HTML文件中传递。 我可以从html文件中检索并设置作为参数传递的矩形的坐标,但我无法从html文件中设置作为参数传递的颜色,如何做到这一点?我试过这个代码,但它不能正常工作
import java.awt.*;
import java.applet.*;
/* <applet code="ParaRect" width=1200 height=1000>
<param name=x value=100>
<param name=y value=200>
<param name=color value="red">
</applet> */
public class ParaRect extends Applet{
public void paint(Graphics g){
String x=getParameter("color");
g.setColor(Color.x);
g.fillRect(Integer.parseInt(getParameter("x")),Integer.parseInt(getParameter("y")),150,100);
}
}
# 1 楼答案
g.fillRect(Integer.parseInt(getParameter(“x”)),Integer。parseI nt(getParameter(“y”)),150100; }
}“'