# Problem with surface.setResizable(true)

**URL:** <https://discourse.processing.org/t/problem-with-surface-setresizable-true/46905>\
**Category:** Processing\
**Created:** [August 11, 2025, 2:10pm UTC](https://discourse.processing.org/t/problem-with-surface-setresizable-true/46905 "2025-08-11T14:10:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [August 11, 2025, 2:10pm UTC](https://discourse.processing.org/t/problem-with-surface-setresizable-true/46905/1 "2025-08-11T14:10:17Z")

</div>

Hello,

surface.setResizable(true) : and the sketch window is resizable.

Problem : if width and height are used, they are not updated anymore when you resize the window

(Processing 4.4.4 + Linux Mint)

See this code :

```auto
float width2;
float height2;

void setup() {
  size(800, 600);
  surface.setResizable(true);
  textSize(20);
}

void draw() {
  width2=width;
  height2=height;
  background(color(0,0,255));
  rectMode(CENTER);
  stroke(255);
  text("Width : "+width,40,50);
  text("Height : "+height,40,100);

// This works :
  rect(width2/2,height2/2,100,100);
  
  // This doesn't work !!! WHY ?
  //rect(width/2,height/2,100,100);
}

```

and **sometimes** , it doesn’t work in any case !

---

<div class="post-metadata">

**Author:** ![stefterv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stefterv/32/21678_2.png) [@stefterv](https://discourse.processing.org/u/stefterv)\
**Post date:** [August 11, 2025, 2:42pm UTC](https://discourse.processing.org/t/problem-with-surface-setresizable-true/46905/2 "2025-08-11T14:42:47Z")

</div>

It works for me on macOS, I will check on my linux mint VM

---

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [August 11, 2025, 7:11pm UTC](https://discourse.processing.org/t/problem-with-surface-setresizable-true/46905/3 "2025-08-11T19:11:03Z")

</div>

with : rect(width/2,height/2,100,100); and not rect(width2/2,height2/2,100,100); ?

🙂

P.S. I know about : windowRatio() !

---

<div class="post-metadata">

**Author:** ![stefterv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stefterv/32/21678_2.png) [@stefterv](https://discourse.processing.org/u/stefterv)\
**Post date:** [August 12, 2025, 8:05am UTC](https://discourse.processing.org/t/problem-with-surface-setresizable-true/46905/4 "2025-08-12T08:05:35Z")

</div>

Ah, so it’s a different issue, the processing sketch crashes on resize, we have seen this issue before.

Can you use P2D for now? That is less likely to crash

---

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [August 12, 2025, 10:59am UTC](https://discourse.processing.org/t/problem-with-surface-setresizable-true/46905/5 "2025-08-12T10:59:19Z")

</div>

Thank you very much !

Now it works in the tiny example (and in my PstarEngine project too !).

💝
