when I compile this... it says that the Variable "Width" in my method "slowShow()" is undefined. how do I get around solving this? I cant define width as an instance variable as it comes into play only after the constructo uses the argument int pixels. pls help me out yall! cheers
[This message has been edited by Fahed Ghazali (edited May 13, 2001).]
Bosun is correct, the problem is that you have declared and initialized the width (and height) variable inside your constructor, and it is therefore local to that constructor. Once it is over the rest of the code can't see it. To prevent this, declare the variable outside the constructor, and just initialized it in the constructor. This way the methods will be able to access it later. You are also going to have a problem with you GrayScaleCanvas because you declared it as an instance variable and then REDECLARED it in the constructor - which created a DIFFERENT variable with the same name but local to the method. When you initialize gsc do NOT redeclare it.
[This message has been edited by Cindy Glass (edited May 13, 2001).]
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: May 06, 2001
Thanx... appreciate the help guys!! now another slight problem! in my original code right... I have also initialised the argument intpixels in the constructor... coz thass where Im gonna get the information from. But I need to use the 2d array pixels an all my other methods. How do I declare this as an instance variable? do I just add intpixels as an instance variable n then in the constructor what do I do to make it equal to the intpixels in the argument??
this might seem trivial to yall...... but Im still learning ppl! cheers thanx