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.
Page Index Toggle Pages: 1
class (Read 360 times)
class
Nov 19th, 2009, 9:25am
 
Hi,

I'm beginning in processing, and I need to do a basic slider
(those of libraries like ControlP5 are too complicated for me at the moment, and I would to modify styles)

So I started to make one, and I have already problems...

It say me that there is an NullPointer exception

There my code :

Code:

Slider slider1;

void setup(){
 /////////////////////////////////////
 size (500,500);
 background(120);
 /////////////////////////////////////

 Slider slider1 = new Slider(20,20,100,20);
}

void draw(){
 slider1.dessiner();
}

class Slider{
 int sPosX, sPosY;
 int sLargeur, sHauteur;
 //int sMin, sMax;
 //int sInitial;
 //int nom;
 //int valeur;

 Slider(int isPosX, int isPosY, int isLargeur, int isHauteur){
   sPosX = isPosX;
   sPosY = isPosY;
   sLargeur = isLargeur;
   sHauteur = isHauteur;
 }

 void dessiner(){
   noStroke();
   fill(150);
   rect(sPosX,sPosY,sLargeur,sHauteur);
   fill(80);
   rect(sPosX,sPosY,sLargeur,sHauteur);
 }

 /*void bouger(){
  if(mousePressed){
  rect(sPosX,sPosY,mouseX-sPosX,sHauteur);
  }
  }*/
}



if someone can have a look, thank you !
Page Index Toggle Pages: 1