Results 1 to 5 of 5
  1. #1
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default why do I got this error about the constructor ?

    I have the class ImagePanel with this code:

    cF = new CaptureFrame(this, url, img);



    and the class CaptureFrame with this code:

    Image img;
    URL url;
    ImagePanel iPanel;

    CaptureFrame(ImagePanel iPanel, Image img, URL url ) {
    this.img = img;
    this.url = url;
    this.iPanel = iPanel;
    ...



    I got the following error:

    ./ImagePanel.java:52: cannot find symbol
    symbol : constructor CaptureFrame(ImagePanel,java.net.URL,java.awt.Imag e)
    location: class CaptureFrame
    cF = new CaptureFrame(this, url, img);
    ^
    1 error

    why ?

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Let's find out what "this" is:
    Java Code:
    //cF = new CaptureFrame(this, url, img);
    System.out.println("this = " + this.getClass().getName());
    It refers to the enclosing class, eg, an anonymous inner class.

  3. #3
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default

    output:
    this = ImagePanel

    it is correct... I can't understand...

  4. #4
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Java Code:
    cF = new CaptureFrame(this, url, img);
    // The argument types do not match.
    CaptureFrame(ImagePanel iPanel, Image img, URL url )
    // To use this constructor you would do:
    cF = new CaptureFrame(this, img, url);

  5. #5
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

Similar Threads

  1. "Cannont find symbol Constructor" error
    By Welsh in forum New To Java
    Replies: 7
    Last Post: 01-25-2008, 12:12 AM
  2. Replies: 0
    Last Post: 12-19-2007, 09:10 AM
  3. Replies: 0
    Last Post: 12-19-2007, 09:01 AM
  4. Constructor Help
    By bluegreen7hi in forum New To Java
    Replies: 2
    Last Post: 11-15-2007, 05:44 AM
  5. Error: cannot find symbol constructor
    By zoe in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 08:24 PM

Posting Permissions

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