We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › class outside PApplet
Page Index Toggle Pages: 1
class outside PApplet (Read 532 times)
class outside PApplet
Nov 26th, 2007, 5:56am
 
hi all,
i currently use the processing bundle for textmate, which lets me hit 'command r' to run my code in the PDE. i just went through the eclipse tut at:
http://www.mostpixelsever.com/tutorial/eclipse

and would like to be able to do the same thing in textmate, still running the code in the PDE. but when i run this code:

/*****************/

public class java_1 extends PApplet {
//
An array of stripes

Stripe[] stripes = new Stripe[50];


public void setup() {


size(200,200);


// Initialize all "stripes"


for (int i = 0; i < stripes.length; i++) {



stripes[i] = new Stripe(this);


}

}


public void draw() {


background(100);


// Move and display all "stripes"


for (int i = 0; i < stripes.length; i++) {



stripes[i].move();



stripes[i].display();


}

}
}

public class Stripe {

float x;       // horizontal location of stripe

float speed;   // speed of stripe

float w;       // width of stripe

boolean mouse; // state of stripe (mouse is over or not?)

PApplet parent; // The parent PApplet that we will render ourselves onto


Stripe(PApplet p) {


parent = p;


x = 0;              // All stripes start at 0


speed = parent.random(1);  // All stripes have a random positive speed


w = parent.random(10,30);


mouse = false;

}


// Draw stripe

void display() {


parent.fill(255,100);


parent.noStroke();


parent.rect(x,0,w,parent.height);

}


// Move stripe

void move() {


x += speed;


if (x > parent.width+20) x = -20;

}
}

/*******************/


i get this error:
java.lang.InstantiationException: Stripe

at java.lang.Class.newInstance0(Class.java:335)

at java.lang.Class.newInstance(Class.java:303)

at processing.core.PApplet.main(PApplet.java:6937)


any help appreciated. and another much more embarassing question - how do you format code in the forums!?
Page Index Toggle Pages: 1