null error in string
in
Programming Questions
•
8 months ago
Hello I have made this class, and I am trying to add some text in it, but for some reason it gives me a null error, can somebody tell me why?
thanks in advance
- Button b1 = new Button(1, "Grayscale");
- void setup()
- {
- size(500, 350);
- }
- void draw() {
- b1.display();
- }
- class Button {
- boolean clicked = false;
- int nr, x, y, w, h;
- String name;
- Button (int nr, String inName) {
- inName = name;
- w = 70;
- h = 20;
- x = nr*(w+10)-w;
- y = 350-(h+10);
- }
- void display() {
- rect(x, y, w, h);
- text(name, x, y); //getting null error
- }
- }
1