My library constructor is undefined

Hello,

I'm having a 'constructor is undefined' error that makes little sense. The initial code of my library is:

package gazetrack;

import processing.core.*;
import java.lang.reflect.Method;


public class GazeTrack
 {
        PApplet myParent;
        private GazeStream dataStream;
        private Method gazeStopped, gazeStarted;


    public GazeTrack(PApplet myParent)
    {
        this.myParent = myParent;
        myParent.registerMethod("dispose", this);
        initGazeTrackMethods();

        welcome();

        dataStream = new gazetrack.GazeStream(this);
    }
...

}

And in Processing:

import gazetrack.*;

GazeTrack gt;

void setup()
{
      size(displayWidth, displayHeight);
      gt = new GazeTrack(this);
}

The error is the following:

The constructor GazeTrack(GazeTrack) is undefined.

Answers

  • edited October 2014

    Dunno what's wrong either. Deducing from "The constructor GazeTrack(GazeTrack) is undefined.", you're trying to pass a GazeTrack rather than a PApplet reference to it! @-)
    Dunno why would it think that the this in gt = new GazeTrack(this); wouldn't be a PApplet? :-/

  • I think the problem is not what I'm passing to the constructor. If I change:

    public GazeTrack(PApplet myParent) to public GazeTrack(int test)

    and

    gt = new GazeTrack(this); to gt = new GazeTrack(2);

    I still get:

    The constructor GazeTrack(int) is undefined.

  • Answer ✓

    i'm guessing your project is called GazeTrack. so you have actually have two classes called GazeTrack... try changing the project name or the object name

  • edited October 2014

    It's still weird saying "The constructor GazeTrack(GazeTrack) is undefined."!
    It shoulda been: "The constructor GazeTrack(PApplet) is undefined."
    That is, somehow, it thinks that setup() lives in a GazeTrack instead of PApplet class!

  • edited October 2014

    Oh, like @koogs said, that is much probably the culprit. Processing's pre-processor uses the name of the 1st main tab as the wrapper class name for all the ".pde" tabs!
    You got a a class name collision there! (~~)

  • Answer ✓

    I suspect that your sketch is also called GazeTrack. Processing wraps up you sketch in a class with the same name.

  • It's finally working :) Thanks everyone!

  • It is an error so classical it was in the Technical FAQ for which I still must find some time to restore...

Sign In or Register to comment.