Perry Smith

Java Questions & Answers

Home / Java Q & A Archive Page 3 / Java Q & A Archive

Graphics class again
Sunday, 24-Jan-99 23:55:13

203.129.225.221 writes:

I want to know that how does the component object create an instance of the graphics class though its an abstract class. By the rule or concept one can not create an instance of an abstract class. So i want to know the method by which the component class creates the instance internally.

Anand Gore


Response
create graphic in component
Monday, 25-Jan-99 04:54:43

194.158.187.242 writes:

The following method should do the trick:

public Graphics createNewGraphics {
Image newImage;
Graphics newGraphics;

newImage = this.createImage(this.size().width, this.size().height);
newGraphics = newImage.getGraphics();

return newGraphics;
}

Please note that only drawings to the original graphics will have effect on screen.

Henk Jan, HJNoot@sum-it.nl


Home / Java Q & A Archive Page 3 / Java Q & A Archive