Almost done with program, just a little help please

I am almost done with a program but I just need to have the planet which is _ball be painted on the screen. I am making a planet that orbits a sun, it all works but the planet is not painted on the screen, but I used a fill method. Can you guys help?

publicclass MovingBallextends SmartEllipse

{

int X0 = 100, Y0 = 100;

double X2, Y2;

double r = 10;

double a = 0;

double da = .04;

double ecc = 1;

double TWOPI = 2 * Math.PI;

private javax.swing.JPanel _panel;

public MovingBall (java.awt.Color aColor, javax.swing.JPanel aPanel)

{

super(aColor);

_panel = aPanel;

X2 = X0 + r * Math.cos(a);

Y2 = Y0 + r * Math.sin(a);

this.setLocation(X2, Y2);

}

publicvoid move()

{

a = a + da;

a = a % TWOPI;

X2 = X0 + r * ecc * Math.sin(a);

Y2 = Y0 + r * ecc * Math.sin(a);

this.setLocation (X2, Y2);

}

publicboolean inFront()

{

return (a <= Math.PI);

}

publicvoid SetCircle(int x,int y)

{

X0 = x;

Y0 = y;

//ecc = 1.0 - (double)pct/100;

}

publicvoid setAngleIncrement(double inc)

{

da = inc;

}

publicvoid setCenter(double g,double s)

{}

}

publicclass MovingBallPanelextends javax.swing.JPanelimplements Mover, Controller

{

privatefinalint INIT_X = 250;

privatefinalint INIT_Y = 200;

private SmartEllipse _sun;

private Sky _sky;

privatefinalint SUN_DIAMETER = 60;

private MovingBall _ball;

privatefinalint PLANET_DIAMETER = 35;

privatefinalint ORBIT_DIAMETER = 185;

int _da = 1;

int _ecc = 1;

privatefinalint INTERVAL = 100;

private MoveTimer _timer;

public MovingBallPanel()

{

super();

this.setBackground(java.awt.Color.BLACK);

_sun =new SmartEllipse(java.awt.Color.YELLOW);

_sun.setSize(SUN_DIAMETER, SUN_DIAMETER);

_sun.setLocation(INIT_X - SUN_DIAMETER/2, INIT_Y - SUN_DIAMETER/2);

_sky =new Sky();

_ball =new MovingBall(java.awt.Color.RED,this);

_ball.setCenter((INIT_X - PLANET_DIAMETER)/2, (INIT_Y - PLANET_DIAMETER)/2);

_ball.setAngleIncrement(_da);

_timer =new MoveTimer(INTERVAL,this);

_timer.start();

}

publicvoid move()

{

_ball.move();

this.repaint();

}

publicvoid go (boolean g)

{

if (g) _ball.setAngleIncrement(_da);

else _ball.setAngleIncrement(0);

}

publicvoid setSpeed(int degrees)

{

_da = 2 * degrees;

_ball.setAngleIncrement(_da);

}

publicvoid setEccentricity(int pct)

{

_ecc = pct;

//_ball.setEccentricity(_ecc);

}

publicvoid paintComponent(java.awt.Graphics aBrush)

{

super.paintComponent (aBrush);

java.awt.Graphics2D betterBrush = (java.awt.Graphics2D) aBrush;

_sky.paintSky(betterBrush);

_sun.draw(betterBrush);

_sun.fill(betterBrush);

_ball.draw(betterBrush);

_ball.fill(betterBrush);

}

}

publicclass PlanetAppextends javax.swing.JFrame

{

ControlPanel _controlPanel;

MovingBallPanel _movingBallPanel;

public PlanetApp (String title)

{

super(title);

this.setSize(600,500);

this.setBackground(java.awt.Color.BLACK);

this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);

_movingBallPanel =new MovingBallPanel();

_controlPanel =new ControlPanel(_movingBallPanel);

this.add(_movingBallPanel, java.awt.BorderLayout.CENTER);

this.add(_controlPanel, java.awt.BorderLayout.SOUTH);

this.setVisible(true);

}

publicstaticvoid main (String [] args)

{

PlanetApp app =new PlanetApp("Lab 5");

}

}

publicclass SmartEllipseextends java.awt.geom.Ellipse2D.Double{

private java.awt.Color _borderColor, _fillColor;// attributes

privateint _rotation;

privatefinalint STROKE_WIDTH = 2;

public SmartEllipse(java.awt.Color aColor){

_borderColor = aColor;

_fillColor = aColor;// solid color to start

_rotation = 0;// no rotation for now

}

// methods not provided by Java

publicvoid setBorderColor (java.awt.Color aColor){

_borderColor = aColor;

}

publicvoid setFillColor (java.awt.Color aColor){

_fillColor = aColor;

}

publicvoid setRotation (int aRotation){

_rotation = aRotation;

}

// more readable versions of methods provided by Java

publicvoid setLocation (double x,double y){

this.setFrame (x, y, this.getWidth(),

this.getHeight());

}

publicvoid setSize (int aWidth,int aHeight){

this.setFrame(this.getX(), this.getY(),

aWidth, aHeight);

}

publicvoid move (int aChangeInX,int aChangeInY){

this.setFrame((int)this.getX()+aChangeInX,

(int)this.getY()+aChangeInY,

this.getWidth(),

this.getHeight());

}

publicvoid fill (java.awt.Graphics2D aBetterBrush){

java.awt.Color savedColor = aBetterBrush.getColor();

aBetterBrush.setColor(_fillColor);

aBetterBrush.fill(this);// paint a solid ellipse

aBetterBrush.setColor(savedColor);

}

publicvoid draw (java.awt.Graphics2D aBrush){

java.awt.Color savedColor = aBrush.getColor();

aBrush.setColor(_borderColor);

java.awt.Stroke savedStroke = aBrush.getStroke();

aBrush.setStroke(new java.awt.BasicStroke(STROKE_WIDTH));

aBrush.draw(this);

aBrush.setStroke(savedStroke);

aBrush.setColor(savedColor);

}

}

[11728 byte] By [telk02a] at [2007-10-2 21:22:32]
# 1
?
telk02a at 2007-7-14 0:32:52 > top of Java-index,Java Essentials,Java Programming...