开发者

paintComponent question

What purpose does super.paintComponent(g) serve in this sample code?

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);
        }
    }
}


super tutorial http://download.oracle.com/javase/tutorial/java/IandI/super.html


That is dependent upon what super class you override the paintComponent-method from. But as a answer it has the purpose of calling the super class version of the same method before the overriden is run.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜