Copy and paste the following code.
public void act()
{
move(10);
bounceOffPaddles();
ifOnEdgeBounce();
}
public void ifOnEdgeBounce()
{
int x = getX();
int y = getY();
if (x >=getWorld().getWidth() -1)
{
setRotation (180 - getRotation());
}
if (x < 1)
{
setRotation (180-getRotation());
}
if (y >= getWorld().getHeight() -1)
{
setRotation (360-getRotation());
}
if (y<1)
{
setRotation (360-getRotation());
}
setLocation(x,y);
}