I'm trying to make the ball move to a specific place then falls into the bottom of the app

and this is an quick image I made to make it clear
[IMG]http://img845.imageshack.us/img845/6651/sssssv.gif[/IMG]

and this is what I've been doing , I know it's a mess :S

private float ballRadius = 20; // Ball's radius
   private float ballX = ballRadius + 150; // Ball's center (x, y)
   private float ballY = 350;
   private float ballSpeedX = 3;   // Ball's speed for x and y
   private float ballSpeedY = 2;
.
.
.


  ballX += ballSpeedX;
           
               
               if (ballX >350) {
                  ballSpeedX = -ballSpeedX; // Reflect along normal
                  ballX = ballRadius; // Re-position the ball at the edge
            }
                  else if (ballX + ballRadius > 350) {
                  ballSpeedX += ballSpeedX;
                  ballX = 350 - ballRadius;
               }
               // May cross both x and y bounds
             if (ballY - ballX == 280) {
                  ballSpeedY = 10;
                ballY = ballRadius;
               } else if (ballY + ballRadius > BOX_HEIGHT) {
                ballSpeedY = -ballSpeedY;
                  ballY = 70 - ballRadius;
               }


.
.
.
.

public void paintComponent( Graphics g ) {
        super.paintComponent(g);
// Draw the ball
      g.setColor(Color.BLUE);
      g.fillOval((int) (ballX - ballRadius), (int) (ballY - ballRadius),
            (int)(2 * ballRadius), (int)(2 * ballRadius));

any help ???

man, your code really is a mess. try fixing it a little first and then someone will surely help you. this problem is a simple problem that would easily be solved had you provided a complete class, one that includes the imports, a class name, putting pieces of code inside methods... try doing that first friend, I really don't know where to start helping you.

look this is the code that our Dr GAVE IT to us
and I was editing it

ballX += ballSpeedX;
               ballY += ballSpeedY;
               // Check if the ball moves over the bounds
               // If so, adjust the position and speed.
               if (ballX - ballRadius < 0) {
                  ballSpeedX = -ballSpeedX; // Reflect along normal
                  ballX = ballRadius; // Re-position the ball at the edge
               } else if (ballX + ballRadius > BOX_WIDTH) {
                  ballSpeedX = -ballSpeedX;
                  ballX = BOX_WIDTH - ballRadius;
               }
               // May cross both x and y bounds
               if (ballY - ballRadius < 0) {
                  ballSpeedY = -ballSpeedY;
                  ballY = ballRadius;
               } else if (ballY + ballRadius > BOX_HEIGHT) {
                  ballSpeedY = -ballSpeedY;
                  ballY = BOX_HEIGHT - ballRadius;
               }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.