title: call a method from a Rectangle class in the main class
body: <p>I am trying to retrieve a method from the Rectangle Class in the Main Class, but it is not working. The goal would be that the user clicks on the Rectangle button and then a Rectangle appears. However, the rectangle must not disappear again.  Additionally, the user should be able to change the properties (like size and position).</p>
  <p>I am not sure if I should try the callback function? I would really appreciate your help!</p>
  <p>Thanks a lot in advance!</p>
  <pre><code>import controlP5.*;
  import de.bezier.data.sql.*;
  
  Rectangle rect;
  Button rc;
  
  
  int posX = 50; 
  int posY = 60; 
  int w = 100;
  int h = 150;
  
  //Rectangle r = new Rectangle(posX, posY, w, h);
  
  public void drawButton() {
     fill(230, 230, 255);
     stroke(0);
     rect(50, 60, 100, 150);
     
    
  
  }
  public boolean isMouseInsideRectangleButton() {
     return mouseX &gt; posX &amp;&amp; mouseX &lt; posX + w
             &amp;&amp; mouseY &gt; posY &amp;&amp; mouseY &lt; posY + h;
  }
  
  
  ControlP5 cp5;
  
  SQLite db;
  
  void setup(){
    size(1000, 1000);
    //background(255);
    PFont font = createFont(&quot;Calibri&quot;, 15);
    
    rect = new Rectangle(250, 500, 100, 100);
  
    
    cp5 = new ControlP5(this);
    
    cp5.addButton(&quot;Save&quot;).
    setPosition(770, 20).
    setSize(100, 30).
    setFont(font).
    setColorBackground(color(52, 55, 76));
    
    cp5.addButton(&quot;erase&quot;).
    setPosition(890, 20).
    setSize(100, 30).
    setFont(font).
    setColorBackground(color(52, 55, 76));
    
    cp5.addButton(&quot;Upload&quot;).
    setPosition(650, 20).
    setSize(100, 30).
    setFont(font).
    setColorBackground(color(52, 55, 76));
    
    
    rc = cp5.addButton(&quot;Rectangle&quot;).
    setPosition(5,4).
    setSize(100, 20).
    setFont(font).
    setColorBackground(color(52, 55, 76));
     
     rc.onRelease(new CallbackListener() {
       public void controlEvent(CallbackEvent theEvent)
       
       {
         rect.draw();
       }
       
     
  }
     );
     
  }
    
    
    
    
    //cp5.addButton(&quot;Triangle&quot;).
    //setPosition(5,42).
    //setSize(100, 20).
    //setFont(font).
    //setColorBackground(color(52, 55, 76));
    
    //cp5.addButton(&quot;Ellipse&quot;).
    //setPosition(165, 4).
    //setSize(100, 20).
    //setFont(font).
    //setColorBackground(color(52, 55, 76));
    
    //cp5.addButton(&quot;circle&quot;).
    //setPosition(165,42).
    //setSize(100, 20).
    //setFont(font).
    //setColorBackground(color(52, 55, 76));
  
  
  
  
  
  
  
  void draw(){
    
    background(255);
    fill(246, 246, 246);
    stroke(246, 246, 246);
    rect(0,0, 1000, 80);
    
   
  
    
   
  
  
  //public void mousePressed() {
  //  if (isMouseInsideRectangleButton()) {
  //      //r.setDrawColorful(!r.getDrawColorful());
  //      r.draw();
  //  }
    
  }
  
  
  public class Rectangle
  {
    private int posX, posY, w, h;
    
    
    private boolean drawColorful = false;
    
    
    //constructor
    
    public Rectangle(int posX, int posY, int w, int h) {
      this.posX = posX;
      this.posY = posY;
      this.w = w;
      this.h = h;
    
  }
  
  public boolean getDrawColoful(){
    return this.drawColorful;
  }
  
  public void setDrawColorful(boolean flag) {
      this.drawColorful = flag;
    }
    
    
    public void setPosX(int posX){
      this.posX = posX;
    }
    
    public int getPosX(){
      return posX;
    }
    
     public void setPosY(int posY){
      this.posY = posY;
    }
    
    public int getPosY(){
      return posY;
    }
    
     public void setW(int w){
      this.w = w;
    }
    
    public int getW() {
      return w;
    }
    
    public void setH(int h) {
      this.h = h;
    }
    
    public int getH() {
      return h;
    }
  
      
    
    
    
    
  
  public void draw() {
  
   if (this.drawColorful) {
        fill(255,255,0);
        stroke(0,0,255);
        
        
        
      } else {
        fill(255,255,255);
        stroke(0,0,0);
      }
  
  rect(posX, posY, w, h) ;
  
  
  
  
  }
  
  }
  </code></pre>