Movement is "wacky". q and w get wider for some reason. The goal of this is to have the ball move to the other side and stay at the same size. What am I doing wrong?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Why do you still create a timer within your paintComponent method? Each repaint there will be another timer, and therefore your movements become faster and faster.
And where is the call to super.paintComponent? And why are your variables Doubles instead of doubles? Again, move the timer code to the constructor. It doesn't belong in the paintComponent method.
Your timer increases not only "w" (the X location) but also "q" (the width). That's why your ellipse is increasing in size each time.
- move the timer code to the newly created constructor.
- add super.paintComponent(g).
- remove the code that increases "q".
You don't need to; line 48 from my code does the same. But yes, setting it from the constructor should also work. Don't set the background from the painting code, because I believe it will trigger another repaint - which will set the color which will trigger another repaint, etc.