public void Filler(Graphics g) {
super.paintComponent(g);
g.setColor(Color.black);
g.drawRect(Height, Width, 12, 12);
}
我如何称呼Filler
void
,因为显然它不想让我只做Filler();
吗?
让我们看看您要调用的方法
public void Filler(Graphics g) {
super.paintComponent(g);
g.setColor(Color.black);
g.drawRect(Height, Width, 12, 12);
}
注意在哪里显示(Graphics g)
?这些被称为参数,这基本上意味着您要调用requires的方法将其传递给该参数的值。
在这种情况下,要调用您的方法,必须将其传递给Graphics对象。
所以您会这样称呼它:
Graphics g = new Graphics(); // creating this object also might require arguments to be passed!!
filler(g);
您不能只做filler();因为这意味着您没有传递任何值。