Hello Guys I'm Trying Two Create a Program Which Has a Two ball in it. The One is Going right and the one is going down. i have a code but i don't know how to make the other ball going down... any help is much appreciate thanks...
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class move extends JPanel
{
   Timer timer;
   int x = 0, y = 10, width = 40, height = 40;
   int radius = (width / 2);
   int frXPos = 500;
   int speedX = 1;
   move()
   {
        ActionListener taskPerformer = new ActionListener() 
        {
            @Override
            public void actionPerformed(ActionEvent ae)
            {
                if (x == 0)
            {
                speedX = 1;
            }
            if (x > (frXPos - width)) 
            {
                x=0;
            }
        x = x + speedX;
        repaint();
        }
    };
timer = new Timer(2, taskPerformer);
timer.start();
}
@Override
public void paintComponent(Graphics g)
{
     super.paintComponent(g);
     g.setColor(Color.red);
     g.fillOval(x, y, width, height);
}
}
class MovingBall
{
MovingBall()
{
     JFrame fr = new JFrame("Two Balls Moving Other Ways");
     move o = new move();
     fr.add(o);
     fr.setVisible(true);
     fr.setSize(500, 500); 
     fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[])
{
        MovingBall movingBall = new MovingBall();
}
}