Re: how to unpaint my circle
Your primary problem is that your paint method doesn't call the super.paint(g); method as its first method call. But you have other problems as well:
- You shouldn't be drawing directly in a JFrame and
- You especially shouldn't be animating in a JFrame, unless you want choppy animations.
- Instead draw/animate in a JPanel
- and do your drawing in its paintComponent method override, not its paint method.
- The first line of your paintComponent method override should be a call to the super's paintComponent method (analogous to for the paint method).
- Rather than use background threads for simple animations, consider using a Swing Timer.
Also, please check out my link on using code tags when posting code here.
Much luck!
Re: how to unpaint my circle
- To improve efficiency, don't construct a new Ellipse2D every time through the painting method. Maintain one Ellipse2D as an instance field, possibly final, and mutate it before painting.
- Similarly, cache the Color(75,0,130), possibly as a static final field.
db