It took me a few bits to remember what this was for. It's sort of a brownian motion ball that will run towards wherever you click, and detects if you move out of the box (changes blue) or in (back to red), and runs after the point where you exited. It doesn't do the exact diagonal to where you click, rather, it runs at 45 degrees until it matches horizontally or perpendicularly with the appropriate point, then goes straight. Don't remember why it did that. The flickering is due to a lack of double-buffering. The (very small) code is here: Ball.java.
For something a step niftier, see Bear.