Re: Graphics help please



On Sat, 26 Jan 2008 20:31:18 -0000, Knute Johnson <nospam@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

You've got a bunch of problems. Drawing Swing components must occur in the paintComponent() method not paint(). You can't pause in the paintComponent() method and get it to work. So what you need to do is keep the state somewhere else and draw it in the paintComponent(). You can use an offline image as you did but it is not necessary. I use the volatile variable 'angle' to store the current drawing state. Using a separate thread to set the angle makes it really easy to have many different threads doing different things. In the example below I start the thread running right after setting the frame visible but it could easily be started with a button.


Thanks, I'll give that a go and see if I can adapt it to my use.
.