Hi folks,
I've been learning
Java and OOP in my spare time for fun lately. After finishing with Head First Java, I'm currently reading through Daniel Liang's excellent Introduction to Java Programming Comprehensive and Core Java Vol 1. I'm currently programming some of the exercise problems at the end of the Event driven programming chapter of the first book. Here is the exercise problem:
Write a program that displays a circle of radius 10pixels filled with a random color at a random location on a panel. When you click the circle, it is gone and a new random-color circle is displayed at another random location. After twenty circles are clicked, display the time spent in the panel.
I've coded this up and it works perfectly, except that when clicking in rapid succession, some of the clicks are not registered. I have noticed this with other programs I have written as well, and when I run the compiled class files provided by the author of the book (to try running all the exercise problems), I observe a similar behavior. Is this a concurrency issue due to conflicts with the GUI EDT? I haven't read up on threads and concurrency yet, but if that is the case, I'd like to identify where the issue is being produced. With the bug as is, this exercise is a bit pointless because you can never get a great "score" due to the unregistered click events.
PS - I have added in some stuff to avoid bugs when resizing the window. I know that I could have set it to not be resizable, but I was just playing around with the code to see if I could handle that case without making a hash of things. Also, I'd appreciate any general comments about the program and what I could do to improve it.