在jbuilder里写一个applet用到Graphics编译错误
我在jbuilder新建了一个applet,写了一个根据参数画矩形的小程序,但是有个地方报错,是要写什么变量才可以?麻烦帮忙看看代码,谢谢!
public void actionPerformed(ActionEvent e) { //事件处理方法
String s = e.getActionCommand();
if (s.equals("画图")) {
this.draw(g); //此处报"Applet1.java": cannot find symbol; symbol : variable g, location: class hy.Applet1 at line 32, column 27
//TH.setText(Integer.toString(531531));
}
}
//paint
public void draw(Graphics g) {
h = stringToInt(TH.getText());
w = stringToInt(TW.getText());
try {
g.drawRect(10, 30, h, w);
} catch (Exception e) {
e.printStackTrace();
}
}