The reason the ball constantly moves to the right is because when it gets into the if statement to set moveRight to false, it returns true to true at the beginning of the method. You need to pull moveRightas a class variable if you want it to work the way you think.
How about this?
private boolean moveRight = true;
private void moveBall() {
x = moveRight ? x + 1 : x - 1;
if (x == 300) {
moveRight = false;
} else if(x == 100){
moveRight = true;
}
}