super.paintComponent(g)在此示例代码中的作用是什么?
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.GRAY);
g.fillRect(gridX * 50, gridY * 50, 50, 50);
for (int i = 0;i < 10; i++) {
for (int j = 0;j < 10; j++) {
if (savedTiles[i][j])
g.fillRect(i * 50, j * 50, 50, 50);
}
}
}发布于 2011-06-04 06:07:06
超级教程http://download.oracle.com/javase/tutorial/java/IandI/super.html
发布于 2011-06-04 06:03:04
这取决于您从哪个超类覆盖paintComponent-method。但作为回答,它的目的是在重写运行之前调用同一方法的超类版本。
https://stackoverflow.com/questions/6233091
复制相似问题