aspose file tools*
The moose likes Beginning Java and the fly likes Graphics Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Graphics Class" Watch "Graphics Class" New topic
Author

Graphics Class

Utkarsh Chowdhary
Greenhorn

Joined: Feb 27, 2001
Posts: 6
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?
David Freels
Ranch Hand

Joined: Feb 01, 2001
Posts: 102
Component has a reference to a graphics object; component.getGraphics. Paint is invoke by the VM when an object needs to be painted.
david
usman ahmad
Ranch Hand

Joined: Mar 06, 2001
Posts: 46
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
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

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.


SCJP
Visit my download page
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Graphics Class