There are a lot of bouncing ball tutorials for Processing – see for example the examples section. Start with the simplest example first:
- Bounce / Examples / Processing.org
- Bouncing Ball with Vectors / Examples / Processing.org
- Bouncy Bubbles / Examples / Processing.org
In general, the principle to detect if the ball hits the walls is circle-line collision detection, covered with a working example in this guide:
You may also be interested in one of several video tutorials on the bouncing ball problem: