الاحبة الاعزاء ارجو المساعدة في هذا البرنامج
كيف استطيع ان اجعل الكرة تتحرك داخل الفريم وما تطلع ابدا اضلل داخله
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import static javax.swing.JOptionPane.*;
import java.awt.*;
public class Ball{
private final int RADIUD = 10,CHANGE = 3;
private Point pos;
private Color ballColour = Color.blue;
private int height, width;
public Ball(int frameWidth, int frameHeight){
width = frameWidth;
height = frameHeight;
pos = new Point(100,100);
}
public void paint(Graphics g){
g.setColor(ballColour);
g.fillOval(pos.x - RADIUD,pos.y-RADIUD,2*RADIUD, 2*RADIUD);
}
public void move(){
if(pos.y < height - RADIUD )
pos.translate(0,CHANGE);
}
}
import java.awt.*;
import javax.swing.*;
public class MovingBallFrame extends JFrame{
protected final int FRAME_WIDTH = 240;
protected final int FRAME_HEIGHT = 340;
private Ball myBall = new Ball(FRAME_WIDTH,FRAME_HEIGHT);
public MovingBallFrame (String title){
super(title);
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics g){
super.paint(g);
myBall.paint(g);
}
public void move(){
while(true){
myBall.move();
repaint();
try{
Thread.sleep(50);
}catch (InterruptedException e){
System.exit(0);
}
}
}
}
public class main {
public static void main(String[] args){
MovingBallFrame world = new MovingBallFrame("");
world.setVisible(true);
world.move();
}
}