I am making a game and I have a Restart-function. I have looked around and found this: How to restart a JFrame when creating a multiple level game? but in my program I extend JFrame so I can't just simply .remove(). Anyone got any idea on how to solve this? Thanks.
Asked
Active
Viewed 351 times
0
-
1What is it about your code that prevents you from calling .Remove()? Do you have an example of your code? – JoelC Dec 12 '14 at 14:03
-
Because when I extend JFrame I don't have this in my code: private static JFrame frame; So I can't simply just use frame.remove(). The comment which got removed who said .dispose() worked. But then I want to restart it again. – Fjondor Dec 12 '14 at 14:12
-
You don't have to use `frame.remove()`. Your class extends `JFrame` so just do `this.remove()` or simply `remove()`. – TNT Dec 12 '14 at 14:13
-
I used this.removeAll(); and so the game freezes but all the graphics remain. I want to restart it :/ – Fjondor Dec 12 '14 at 14:18
-
2Don't extend `JFrame`; update its content. – trashgod Dec 12 '14 at 14:25
-
2See also the reset button handler in this [example](http://stackoverflow.com/a/3072979/230513). – trashgod Dec 12 '14 at 15:02