Intégrer une méthode pour fillOval()

Fermé
alexp23 Messages postés 87 Date d'inscription lundi 28 novembre 2011 Statut Membre Dernière intervention 15 avril 2014 - 19 mars 2014 à 11:38
Bonjour, j'ai un problème, je n'arrive pas à intégrer une méthode pour faire bouger un dessin fillOval, voici mon code :

package balle;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;

public class Balle1 extends JPanel{
int x1 = 10, y1 = 10;

public Balle1(){


}


public void paint(Graphics g){
g.setColor(Color.CYAN);
g.fillOval(x1, y1, 30, 30);
}




public void go(int Px, int Py, int Vx, int Vy){
boolean retourX = false;
boolean retourY = false;
while(true){

if (Px < 1){ retourX = false; }
if (Py < 1){ retourY = false; }

if (Px > this.getWidth() - 30) { retourX = true; }
if (Py > this.getHeight() - 30){ retourY = true; }


if (retourX){ Px -= Vx; }
if (retourY){ Py -= Vy; }

if (!retourX) { Px += Vx; }
if (!retourY) { Py += Vy; }

repaint();

try {
Thread.sleep(20);
} catch (InterruptedException e) {}

}
}

package balle;

import javax.swing.JFrame;

public class Fenetre extends JFrame{
public Balle1 ba = new Balle1();
public Fenetre(){
this.setContentPane(ba);
this.setTitle("Balle 3.5");
this.setSize(600, 500);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setVisible(true);
ba.go(ba.x1, ba.y1, 1, 1);

}

}

}


je ne vois pas le problème ... Merci de m'aider.