hfx: Graphics is an abstract class. Its only direct subclasses are DebugGraphics and Graphics2D. I doubt that you were working with DebugGraphics q.e.d.
I suspect you were working with a parameter that was declared as Graphics, but the actual instance that was passed to you was an instance of Graphics2D, eg in Swing's paint(Graphics g) or paintComponent(Graphics g) which is why you can cast g to Graphics2D without an error.
ps: Even fillArc is defined as abstract in Graphics; the version you were using must have been the Graphics2D implementation
That's right, nowhere do you need to mention Graphics2D - but that's how the developers of Swing wrote their code. You declare a Graphics parameter, but they actually give you an instance of Graphics2D, which is OK for you because that's a subclass of Graphics.
It has to work that way because Graphics is abstract and fillArc in Graphics is abstract. Since you want to use that method they have to supply you with an instnace of a class in which fillArc is not abstract - ie Graphics2D.
Normally none of this matters, but here the OP is adamant that he doesn't want to use Graphics2D, which he cannot avoid by referring to Graphics instead.
Anyways... It just works, and I'm glad.
Back to the problem...
Using fillArc(), draw your completed "pie" (circle),
section by section (You're trying to animate your "pie" right?).
Put THIS into a loop. Vary the colour and the "starting degree" parameter.
This will get your "pie" to spin/rotate.
Well thanx very much i did as you said but for now I'm stuck in the rotating of my pie
Question how do I get my theta randomly....?
As u mentioned each time I will update my theta through the outer loop and and
Repaint it again right?
inside your loop and always keep track of X.
You'll have to adjust the formula for (counter)clockwise rotation.
(Sorry, but... I don't have my code for this project at home.)
You could put the whole thing in a method and call it with a new X (instead of a loop) as your application is progressing (such as at start up).