开发者

paintComponent question

开发者 https://www.devze.com 2023-03-10 02:40 出处:网络
What purpose does super.paintComponent(g) serve in this sample code? protected void paintComponent(Graphics g) {

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

精彩评论

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

关注公众号