Reputation: 3
So i've created a Snake game but i have somekind fo a theoretical question.
Im using paintComponent to drawImage every pixel, but im also implementing ActionListener so im bound to using actionPerformed method.
my question is: why using repaint() method inside actionPerformed, what is the logic behind that?
public void actionPerformed(ActionEvent e) {
checkCollusion();
move2();
repaint();
}
i tried removing repaint() method but seems like it stopped updating. myquestion is it necessary for using paintComponent again?
Upvotes: 0
Views: 40