Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't understand draw()

 
budsy remo
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
budsy remo
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't understand . Where exactly is the definition at all ? of the draw method
 
Stephan van Hulst
Bartender
Pie
Posts: 4838
34
Chrome Netbeans IDE Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a million darryl and matthew . i found out that the sungraphics2d was the class that implements it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic