Need help with inheritance
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Need help with inheritance

  1. #1
    Join Date
    Sep 2010
    Posts
    2

    Need help with inheritance

    Ok so this is the KernelHandler Class

    public class KernelHandler extends ImageHandler

    I'm getting a cannot find method getWidth()

    getWidth is part of the BufferedImage class

    I know it has something to do with inheritance, but I need help, please

    //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;
    }

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Need help with inheritance

    Post code using CODE tags (see my sig) so it is readable.

    Post the full error message text of any errors you are getting.

    Post all the relevant code - I don't see any mention of BufferedImage in the code you posted. If KernelHandler extends ImageHandler, what makes you think it should have a getWidth() method?

    A prudent question is one-half of wisdom...
    F. Bacon
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center