I made a slider (brightSlider) and I wanted to add it to the colorpicker. But I could not manage to add it, so I want it at least to be visible only the setup group  (SetupGroup)is open.
So in draw(), I wrote a condition for that. But I am getting null pointer exception. I normally get this error when I don't initialize an object. But in this case, I don't know how to initialize a group. What can I do about this issue?
    import controlP5.*; //import ControlP5 library
    import processing.serial.*;
    
    Button button1;
    Group SetupGroup; //Should I somehow initialize this?
    void setup() { //Same as setup in arduino
    
      brightSlider = new BrightSlider(25,30,200,30,0,100); 
    Group SetupGroup = cp5.addGroup("SETUP")
    .setPosition(90,100)
    .setWidth(150)
    .setHeight(30)
    .setFont(font2);
//
//
//}
void draw() {  //Same as loop in arduino
 background(250);    // Setting the background to white
    if(mousePressed){
      brightSlider.checkPressed(mouseX,mouseY);
    }   
        if(SetupGroup.isOpen()){
        brightSlider.display();
        }
//
//
}
I get this error only when I write if(SetupGroup.isOpen()) line.
Here is the error:

 
                        
Yes!
An uninitialized field (except for primitives) in Java is equal to
null.Your code though tries to execute
null.isOpen(), and becausenullis basically nothing, it doesn't have any methods. And trying to execute a method on a non-existing object results in aNullPointerException.