I haven't run your code but I'm guessing your ball will move to one edge of the screen then stop? I added some comments to problem areas of your code. I'll expand on them after the code.
// Only the update code here. It's where the problem is. The rest of the class looks fine.
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
Input input = gc.getInput();
if((ballStartX >=1) && (ballStartX <=300))
ballStartX += 1 ;
if((ballStartX <= 1) && (ballStartX >= 300)) // This will never return true. ballStartX cannot be both less than 1 and greater than 300.
ballStartX -= 1;
if((ballStartY >=1) && (ballStartY <=250))
ballStartY += 1;
if((ballStartY <=1) && (ballStartY >=250)) // Same as above. Never true.
ballStartY -= 1;
if(input.isKeyDown(Input.KEY_A)){
paddleXStart -= 1 ;
if(paddleXStart < 0){
paddleXStart =+ 1 ; // paddleXStart += 1; May want to change to if (paddleXStart < 0) { paddleXStart = 0; }
}
}
if(input.isKeyDown(Input.KEY_D)){
paddleXStart += 1 ;
if(paddleXStart > 439){ // Same as above. Might be better as if (paddleXStart > 439) { paddleXStart = 439; }
paddleXStart -= 1;
}
}
}
Edit: Lost half my post.
As you can see, the ballwill never move left or I think up. I can't remember how Slick's coordinate system is. ballStartX will never be both less than 1 and greater than 300. You'll want to change
if((ballStartX <=1) && (ballStartX >=300))
to
if (ballStartX < 1) || ballStartX > 300)
The same goes for vertical movement.
if(paddleXStart < 0){
paddleXStart =+ 1 ; // paddleXStart += 1; May want to change to if (paddleXStart < 0) { paddleXStart = 0; }
}
The above will not always exhibit the same behavior. If paddleStartX is located at (-0.5, 50) it will be set to (0.5, 50) while a paddle at (-1, 50) will go to (0, 50). Always setting its postion to 0 will fix this.
Your code is framerate-dependent right now. You may want to look at Slick's documentation and wiki and read up on delta time and framerate-independent motion.
ballStartX, ballStartY, paddleStartX, and paddleStartY sound like they store the initial positions of the paddle and ball so they can be returned to their initial configuration when a player scores. Personally I would rename them. However, it's more important that you understand your code since you're the one having to work with it.
You said you're just starting in Java so I'll let you know you may want to be consistent in your bracket usage. Some of your if statements use brackets while others do not. I can understand having single-line ifs not use brackets but some of yours do and some don't. Standardizing this may help readability.
Edit 2: Your ball is only moving one direction when it's on-screen.
if((ballStartX >=1) && (ballStartX <=300))
ballStartX += 1 ;
If you want to change this behavior, which I assume you do, use a velocity variable and do something like
private float ballVelocity = 1f;
// update method
if (ballStartX < 1 || ballStartX > 300) {
ballVelocity *= -1;
}
ballStartX += ballVeocity