好了,所以这是KernelHandler类需要帮助越来越像高(可能继承问题)
public class KernelHandler extends ImageHandler
我得到一个无法找到方法的getWidth()
我知道它有什么做继承,但我需要帮助,请
//Heres the contructor
public KernelHandler(String nameOfFile)
{
super(nameOfFile);
}
// here's the super constructor
public ImageHandler(String nameOfFile){
URL imageURL = getClass().getClassLoader().getResource(nameOfFile);
try
{
myImage = ImageIO.read(imageURL);
}
catch (IOException e)
{
System.out.println("image missing");
}
// Here's the method were trying to use
public static int numOfRedBoxes(String nameOfImg)
{
KernelHandler myHand = new KernelHandler(nameOfImg);
for(int i = 0; i < myHand.getWidth(); i++)
for(int j = 0; j < myHand.getHeight(); j++){
if(img.getRGB(i, j) == red){
numOfRedBoxes++;
}
}
}
return numOfRedBoxes;
}
http://stackoverflow.com/questions/5651499/need-help-getting-height-of-image-possible-inheritance-problem看起来很相似 – 2011-04-13 15:42:32
它(它是我的)我只是忘了登录,所以我无法发表评论或编辑 – 2011-04-13 15:44:12
为了更好地提供帮助,请发布[SSCCE](http://pscode.org/sscce.html)。 – 2011-04-13 15:58:27