• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Graphics class's abstract methods

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I noticed that many of the methods (such as getClipBounds, fillRect etc. etc.) from class Graphics are marked abstract.
According to the definition of abstract, it means that these methods do not have method body (implementation) defined in this class but just method declaration.
So my question is how are we able to use these methods inside the paint method of an applet using an object of Graphics class?
TIA
Seema
 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.awt.Graphics is an abstract class, so there cannot be an object whose class is Graphics. References to type Graphics always refer to objects that are some subclass of Graphics.
So if you try this in your paint(Graphic g) method
"System.out.println(g.getClass().getName())",
you might get something like
"sun.awt.windows.WGraphics".
All the methods that are abstract in Graphics are defined in the actual class of the object to which the reference points.
 
Seema Das
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,
Thanks you very much for the info!
I couldn't find this in any of the 2/3 books that I have.
So it looks like definition of this sun.awt.windows.wGraphics class is hidden from the programmers.
Thanks again!
-Seema
reply
    Bookmark Topic Watch Topic
  • New Topic