This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Next, you would benefit by reading up on a few things:
1) How to draw graphics in Swing. This often involves overriding the paintComponent method of a JPanel (your panel "p" would do nicely here) and drawing inside of this method using the Graphics object passed to the method by the JVM. You would likely change your ball positions and then call p.repaint() to update the image. There are several excellent tutorials on this in the Sun Swing and Graphics tutorial pages.
2) How to do animation. Simple animations would best be coded using a Swing Timer (javax.swing.Timer). Calling Thread.sleep() on the event dispatch thread as you are doing is only going to be guaranteed to put your whole app to sleep for x seconds (here for 10 seconds).