the fill Rect,setColor etc are all abstarct methods.....so how can we direclty use them with a graphics opject....
Printable View
the fill Rect,setColor etc are all abstarct methods.....so how can we direclty use them with a graphics opject....
Did you try to call them? What happened? They should work as defined in the API. Might be abstract methods or an abstract class, but any reference to an object of said class must implement those methods (for example a child class). In cases where a Graphics object is passed to a method (for example in paintComponent ) an abstract class is defined in the API of this method, but at runtime the passed object must implement any abstract methods. Suggested reading:
Abstract Methods and Classes (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance)
On top of what copeg said, the actual Object used by Swing is almost always a Graphics2D instance, which is an extension of Graphics.