Memory leak in small java project

This code is a simple engine for a trivia game. The idea is that the answers show up on the JButtons. To do this, I had to setup a refresh method that deletes everything and repaints it. It seems that every time this method is called, it gets increasingly slow. It gets so slow after about 10 button clicks, that it will stop responding and I will have to manually shutdown the program.

Alright, as said in the comments, you add too many ActionListeners, which results in the problem you described.

Following will be some advice that I'd like to give you.

First of all, you don't have to use the keyword new everytime you want to change the text of the buttons. Garbage collection will get rid of not used buttons, but why do you want new buttons instead of just updating the text on the buttons via setTest(String) which would not invoke any garbage collection.

Lastly, try to use the constructor more, you can actually let everything you need(atleast in this case, not generally) be created when calling the constructor. As an example, you can creat all JButtons in the constructor and add all listeners to the buttons(I'll supply some code below).

I rewrote your code a little bit, it does not have the same functionality that yours had, but it also doesn't crash.

Edit: As far as current code goes, your function refreshAll(WindowComp w, JFrame frame) is not invoked anymore, because there currently is no need for invoking it. I commented it out with this edit after testing the program without the call.