Since I used some bitwise operations, I might as well briefly explain a little about what they mean. First of all, I defined 4 constant integers:
public final int UP=1, DOWN=2, LEFT=4, RIGHT=8;
This is common practice where something needs a value but it's not any basic data type. I'm using these for directions. The question is, why did I pick 1, 2, 4, and 8? Why not 1, 2, 3, and 4 or 0, 1, 2 and 3? The reason is the binary representations of the numbers:
11
210
4100
81000

Notice each number has exactly one '1' and they're in different places. Now, about basic bitwise operations- I used | (OR) and & (AND). What happens when you bitwise-OR two numbers together is if either one of the numbers has a 1 in that spot, so will the result. If both numbers have a 0 in that spot, the result will have a 0. Example:
9 | 5 = 1001 | 0101 = 1101 = 13
When you bitwise-AND two numbers together, BOTH of the numbers must have a 1 in a position for the result to be 1 in that position, and if EITHER number has a 0 in a position, the result will have a 0 in that postion. Example:
9 & 5 = 1001 & 0101 = 0001 = 1
In my program, I do this to identify directions. First of all, a |= b means a = a | b. The same thing can be done with the & operation. So it seems like the bounce operation can only take in 4 possible integers, but in reality it can take in 16. It will only effectively process 8, though. Let's take a look at the code again:
	public void bounce(int direction)
	{
		if ((direction&UP)>0)
			v=-9*Math.abs(v)/10;
		else if ((direction&DOWN)>0)
			v=Math.abs(v);
		if ((direction&LEFT)>0)
			vx=-Math.abs(vx);
		else if ((direction&RIGHT)>0)
			vx=Math.abs(vx);
	}
First of all, what I'm doing is called 'bitmasking'. If you bitwise AND anything with 0, you get 0. for the first if statement, if the last bit is a 1, the answer will be 1, which is greater than 0, so it's up. If the last bit is 0, then direction & UP will be 0, and it will go to the else statement. The else statement bitmasks the second to last bit by ANDing with 0010. If the second to the last bit of direction is 1, then the result will be greater than 0 and it will bounce down. Notice by using the else statement, I don't allow it to bounce both up and down at the same time, even if both the last two bits are 1's- it will just choose up because I checked that first. After that it checks direction&LEFT, which will be greater than 0 if the third to last bit is 1. Else, it checks the 4th bit from the right by doing the bitwise AND on direction and RIGHT. So, let's summarize here:

direction(%16)binarydirection&UPdirection&DOWNdirection&LEFTdirection&RIGHTActual direction
000000000none
100011000up
200100200down
300111200up
401000040left
501011040up/left
601100240down/left
701111240up/left
810000008right
910011008up/right
1010100208down/right
1110111208up/right
1211000048left
1311011048up/left
1411100248down/left
1511111248up/left