Resize window and object in class

Hi all,

I am trying to do a small GUI and I was playing with resize.
So, the following sketch display’s two circles as if they were two LEDs. I start the sketch with a small window, but if I change the window size to fullScreen the LED’s position are not resized.
I understand that the constructor input’s the initial location for each LED but how can resize an object inside a class?
Do I need to detect a change in the window size and set new positions? or is there an easier way to do this?

Thanks in advance


errorLED Temperature_LED;
errorLED EEPROM_LED;

PFont LED_font;

void setup() {
  size(600, 600);
  surface.setResizable(true);
  
  
  Temperature_LED = new errorLED("Temperature",width/8, height/6);
  EEPROM_LED = new errorLED("FFS",3*width/8,height/6);
  LED_font = createFont("Calibri",18);
}

void draw() {
  background(204);
  Temperature_LED.display();
 
  EEPROM_LED.display();
  stroke(0);
  line(0, 0, width, height);
  line(width, 0, 0, height); 
}

class errorLED {
  String name;
  color colorG, colorY, colorR, actualColor;
  float c_x, c_y, diameter;
  String errorMessage;

  errorLED(String _errorName, float xpos, float ypos) {
    this.name = _errorName;
    this.colorG = color(112, 173, 71);
    this.colorY = color(255, 192, 0);
    this.colorR = color(255, 0, 0);
    this.actualColor = color(100);
    this.c_x = xpos;
    this.c_y = ypos;
    this.diameter = 20;
    this.errorMessage = "";
  }

  void display() {
    noStroke();
    ellipseMode(CENTER);
    fill(actualColor);
    circle(c_x, c_y, diameter);
    fill(0);
    textFont(LED_font);
    textAlign(CENTER,CENTER);
    text(name,c_x,c_y - diameter - 10);
    textAlign(LEFT, CENTER);
    text(errorMessage,c_x + diameter + 15, c_y);
    noFill();
    
  }

  void setColor(String colorN) {
    switch (colorN) {
    case "R":
      this.actualColor = colorR;
      break;
    case "G":
      this.actualColor = colorG;
      break;
    case "Y":
      this.actualColor = colorY;
      break;
    }
  }
  
  void setError(String error){
   this.errorMessage = error; 
  }
}

You have to somehow take into account the change. It can be an if test or you use system variables width & height to always position element correctly

I was hoping that the fact the constructor uses width and height to initiate the object would account for those changes but I guess it passes the value not the “reference”.
Thanks

Why would you want to use a local variable when you have access to a system variable? Well you could use the same class in another environment

Because I don’t want to duplicate code. Creating the object class allows be to place multiple LED objects by passing its initial position in the constructor.
But I will change things.
Thanks