我正在尝试在 ActionListener 中使用 Java 绘制方法。但是,当将paint 放在ActionListener 中时,我的编译器会抛出错误,并且尽管导入了java.awt.geom.*,但eclipse 根本无法将paint 识别为方法;
private class NumHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
//Draw Ovals
public void paint (Graphics g)
{
int number;
int x = 10;
int y = 30;
int width = 20;
int height = 10;
number = Integer.parseInt(numberTF.getText());
for (int i = 0; i < number; i++)
{
g.drawOval(x, y, width, height);
x += 5;
y += 5;
width += 5;
height += 5;
}
}
}
}