Ask your own question, for FREE!
Computer Science 21 Online
OpenStudy (jean-luc):

How do I make a ball bounce back in the opposite direction in java??

OpenStudy (jean-luc):

please find attached file for the codes

OpenStudy (jean-luc):

|dw:1448032606578:dw|

OpenStudy (jean-luc):

Ball has to move up and down continuously in a straight line

OpenStudy (anonymous):

You set your jframe size to 500 x 500, so you need to know when it y reaches the boundary of the jframe. When it does reach the boundary, change directions. You might want to offset the boundary to compensate for the radius of the ball.

OpenStudy (anonymous):

U need velocity and work with the y axis since its up/down + u need an actionlistnner

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!