Hey guys, today for some practice, I whooped up a code that generates randomly colored circles (noise) on the screen.
This is the code I wrote:
However, while it's running through that code, because it's not a thread(I think?) it doesn't allow you to close the program by hitting the X in the corner, you have to close it from eclipse.
I (tried) to write a code using a thread, but no circles are painted on the screen then:
Can someone tell me why this doesn't work, and how to fix it?
(Also, just for future reference, because of it painting so many images on the screen, and them not being removed the amount of RAM being used by the program increases by 1Mb every couple of seconds. How would I remove these circles from the screen, would I have to use double buffering?)
If you significantly reduce the number of times you pass through the while loop - to a few hundred or maybe a 1000, you'll see more interesting results, and the GUI will respond to user input as it should once the while loop has completed. There's a lot that can be learned by messing around with a little program like the first one.
Put the second program away and come back to it after studying multi-threading (or concurrency) and graphics in Swing a bit more.
Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795