This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes can't understand draw() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "can Watch "can New topic

can't understand draw()

budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
the draw(shape s) method is declared abstarct in the Graphics2D class then can someone explain that how is it able to perform any functionality at all because according to me if a method is abstract it doesn't have any definition .
Darryl Burke

Joined: May 03, 2008
Posts: 5048

Maybe you missed to notice that the entire Graphics class is abstract, and so is its subclass Graphics2D.

In a painting method override, print the class of the Graphics reference:What does that give you?

luck, db
There are no new questions, but there may be new answers.
budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
Didn't understand . Where exactly is the definition at all ? of the draw method
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4101

The implementation is *somewhere*. The fact that the method is abstract, doesn't mean it doesn't have an implementation. The implementation is simply not in that class, but in a subclass. You shouldn't worry about it, you can still use the method.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

And what Darryl's code does is show you how to find out the exact type of the implementing class, should you be interested.
budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
thanks a million darryl and matthew . i found out that the sungraphics2d was the class that implements it.
I agree. Here's the link:
subject: can't understand draw()
It's not a secret anymore!