gFu
gFu

Reputation: 1639

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

Upvotes: 2

Views: 252

Answers (2)

isakkarlsson
isakkarlsson

Reputation: 1109

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.

Upvotes: 0

Related Questions