Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Graphics Class

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We say abstract class object can't be created.Then how Abstract class Graphics referance is passed in the method paint(Graphics g).When mehod inside abstract class like drawLine is also abstract then where it is defined?
Also plz tell me how the paint method is invoked automatically?
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Component has a reference to a graphics object; component.getGraphics. Paint is invoke by the VM when an object needs to be painted.
david
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll tell you about paint()
When you change a drawing in an applet, you call the repaint() method to repaint the applet surface. The repaint() method calls the update() method. The update() method clears the viewing area and calls the paint() method, which contains the drawing instructions.
I hope this is helpful
Regards,
Usman
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Utkarsh,
What happens is behind the scenes repaint() creates a class that extends graphics and upcasts it to a Grahics reference. It then calls update, passing it this object as a parameter. You will find this behavior throughout the API.
 
rubbery bacon. crispy tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic