JPanel in puzzle game not updating

前端 未结 3 1963
北恋
北恋 2020-11-22 11:24

I have a simple puzzle game. There is an image consisting of 16 tiles (randomly placed). Images are stored in an array and when game is launched they\'re added to main JPane

3条回答
  •  忘掉有多难
    2020-11-22 12:07

    You are adding all of your components again to your JPanel without actually removing any of them. In your addComponents() method, I would first call removeAll(). You might want to rename that method to highlight the side-effects, as it no longer would only be adding components. Perhaps, resetComponents() would be better.

提交回复
热议问题