Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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 Android Security Essentials Live Lessons this week in the Android 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: 4523

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: 3605

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.
Matthew Brown

Joined: Apr 06, 2010
Posts: 4344

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()
Similar Threads
anonymous class
drawing line
Draw Line
Draw a cylinder