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).
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...