Click to See Complete Forum and Search --> : constructor
thor
October 4th, 2000, 03:35 PM
i'm extending the class Canvas and would like to be able to force the construction of it and all it's super classes. is there a way to do this? i would like to do this because i'd like to use createImage(int,int) in the constructor(double buffering) but can't because i get a null exception so i have to do something that looks a little hacky to accomplish the same thing.
thanks
laneh
October 4th, 2000, 04:15 PM
you can use the super
keyword to access the class that you have extended your new class from, using this you can call the constuctor for the class..
also check this out for help:
http://java.sun.com/docs/books/tutorial/java/javaOO/subclass.html
"There are no facts, only interpretations."
-Friedrich Nietzsche
weaver
October 4th, 2000, 04:17 PM
Canvas has 2 constructors. The first one accepts no parameters and the second one accepts a GraphicsConfiguration object. If you want to call the constructor for Canvas and its super classes, put the following line
super();
as the first line in your constructor. This is an explicit call to the super classes constructor.
-------------------------------------------
weaver
icq# 64665116
Please rate this post.
http://weaver.x7.htmlplanet.com
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.