Rendering objects derived from others

I am fairly new to this area of Java and am trying to do something in a way that could be wrong!

I have my own class called Ball which extends Rectangle so I can add a few extra methods to the Rectangle class. In the paint method of the applet, I am using the fillRect() method to render it, with ball.x, ball.y etc. as arguments. However, when the applet is run the Ball doesn’t appear.

Thanks for any suggestions1

Hey this sounds like an object oriented problem. should ball really derive rectangle?
Instead of using fillRect(), use fillOval(). a ball only need x,y,width. Then you can render it with graphics.fillOval(ball.x,ball.y,ball.width,ball.width);
Harley.

That’s a fair point, but what I was really getting at is what if i define an object that derives from a shape? Can I still draw it normally - because when I use the fill method it doesn’t appear.

Extend something like Elipse2D.Double, then just use Graphics2D.fill(this);