For my Introduction to Programming class, we’ve been studying Java through the Netbeans 3.6 (I know there is a more recent version available, but it was released after the class began, and the instructors wanted to use a consistent version. So we’re also using Java 1.4.6). This particular assignment was to use threading to make a ball bounce. Thus, I created an applet with one thread being the GUI part, that decides when to repaint it, and a class for the ball, which dictates when and where the ball moves.
All my code seems to work properly. Each thread is doing exactly what I told it to, and through console output, you can see the position of the ball moving more or less how I told it to (there are some minor possible glitches with the upper and lower limits that I haven’t quite worked out, but they should be comparitively trivial. Likewise, a better model of gravity should also be fairly easy to add once I finish this).
Unfortunately, when I actually run my applet, either in Netbeans or on a web page, nothing whatsoever gets painted. I’m using java.awt.Graphics, and have done so in the past, so I’m somewhat familiar with it. Moreover, I know the “paint” part of my applet itself is being ran, it just won’t run the parts that actually draw anything.
You can find my code at www.willamette.edu/~btrautma/BallBouncer.zip . Be careful regarding stability, as it’s running two active threads the entire time, which could slow down some computers. If anyone can help me, please do so! Note that my instructor looked at my code and program at length, and could not figure out what was going on. Note also that if I use the built in “repaint()” method rather than calling paint() directly, it never actually runs the method at all, which is further compounding my immense confusion.
Please help!
Netbrian