unexpected token: void on setup(){}

hello,

i have exactly the same code and the frame example for controlp5, but i keep getting flagged for this error and i don't see what is wrong. the example works just fine. i am using processing 2.X. i would appreciate and extra pair of eyes.

import java.awt.Frame;
import java.awt.BorderLayout;

import controlP5.*;

private ControlP5 cp5;

ControlFrame interfaceControl;


void setup()  //unexpected token: void
{
    size(1280, 720, OPENGL);

    cp5 = new ControlP5(this);
    interfaceControl = addControlFrame("interfaceControl", 1024, 768);
}

void draw()
{
    background(0);
}

ControlFrame addControlFrame(String theName, int theWidth, int theHeight) {
    Frame f = new Frame(theName);
    ControlFrame p = new ControlFrame(this, theWidth, theHeight);
    f.add(p);
    p.init();
    f.setTitle(theName);
    f.setSize(p.w, p.h);
    f.setLocation(width/2, height/2);
    f.setResizable(false);
    f.setVisible(true);
    return p;
}

public class ControlFrame extends PApplet {
    int w, h;

    int thumbX = 11;
    int thumbY = 5;

    PImage [] hThumbsFiles;
    PImage [] vThumbsFiles;

    File horizontalThumbsFolder;
    File verticalThumbsFolder;

    String [] horizontalThumbsFilenames;
    String [] verticalThumbsFilenames;

    public void setup() {
        size(w, h);
        frameRate(30);

        cp5 = new ControlP5(this);

        hThumbsFiles = new PImage[horizontalImageFiles.length];
        vThumbsFiles = new PImage[verticalImageFiles.length];

        horizontalThumbsFolder = new File(sketchPath("data/images/hThumbnails/"));
        verticalThumbsFolder = new File(sketchPath("data/images/vThumbnails/"));

        char seperator = '.';

        horizontalThumbsFilenames = horizontalThumbsFolder.list();
        verticalThumbsFilenames = verticalThumbsFolder.list();
        //println("files: " + (horizontalThumbsFilenames.length) + ", " + (verticalThumbsFilenames.length) );

        for(int i = 0; i < horizontalThumbsFilenames.length; i ++)
        {
            horizontalThumbsFilenames[i] = horizontalThumbsFilenames[i].substring(0, horizontalThumbsFilenames[i].indexOf(seperator));
            hThumbsFiles[i] = requestImage("data/images/hThumbnails/" + horizontalThumbsFilenames[i] + ".jpg");

            verticalThumbsFilenames[i] = verticalThumbsFilenames[i].substring(0, verticalThumbsFilenames[i].indexOf(seperator));
            vThumbsFiles[i] = requestImage("data/images/vThumbnails/v" + verticalThumbsFilenames[i] + ".jpg");
            // println(i + ": " + horizontalThumbsFilenames[i] + ", " + verticalThumbsFilenames[i]);
            // println();   
        }

        cp5.printPublicMethodsFor(Matrix.class);

        cp5.addMatrix("matrixH")
        .setPosition(142, 100)
        .setSize(320, 140) //275, 125, 5, 5
        .setGrid(thumbX, thumbY)
        .setGap(5, 5)
        .setMode(ControlP5.MULTIPLES)
        for(int i = index; index < thumbX * thumbY; index ++) {
            .setImage(hThumbsFiles[i])
        }
        .setBackground(color(0))
        ;

        cp5.addMatrix("matrixV")
        .setPosition(562, 100)
        .setSize(320, 140) //275, 125, 5, 5
        .setGrid(thumbX, thumbY)
        .setGap(5, 5)
        .setMode(ControlP5.MULTIPLES)
        for(int i = index; index < thumbX * thumbY; index ++) {
            .setImage(vThumbsFiles[i])
        }
        .setBackground(color(0))
        ;

        cp5.getController("matrixH").getCaptionLabel().alignX(CENTER);
        cp5.getController("matrixV").getCaptionLabel().alignX(CENTER);
    }

    public void draw() {
        background(0);
    }

    private ControlFrame() {

    }

    public ControlFrame(Object theParent, int theWidth, int theHeight) {
        parent = theParent;
        w = theWidth;
        h = theHeight;
    }

    public ControlP5 control() {
        return cp5;
    }

    ControlP5 cp5;
    Object parent;
}

thanks in advance,

destro

Answers

  • Not sure if this might be mucking thing up; however, you are using a variable in your size() method in ControlFrame.setup(). P3 is very intolerant of that (assuming this is legacy code).

Sign In or Register to comment.