# Toggling fullscreen

**URL:** <https://discourse.processing.org/t/toggling-fullscreen/44121>\
**Category:** Beginners\
**Created:** [March 19, 2024, 4:54pm UTC](https://discourse.processing.org/t/toggling-fullscreen/44121 "2024-03-19T16:54:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ripolas](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@ripolas](https://discourse.processing.org/u/ripolas)\
**Post date:** [March 19, 2024, 4:54pm UTC](https://discourse.processing.org/t/toggling-fullscreen/44121/1 "2024-03-19T16:54:55Z")

</div>

Hello, i couldn’t find anything useful on the topic about toggling fullscreen (like F11 in browsers for example). Also how do i run a windowed sketch at the size of the screen? Because if I try this:

```auto
void setup(){
  size(displayWidth,displayHeight);
}

```

im getting an error.

Thanks in advance!  
-Ripolas

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [March 19, 2024, 5:36pm UTC](https://discourse.processing.org/t/toggling-fullscreen/44121/2 "2024-03-19T17:36:51Z")

</div>

Hi @ripolas ,

Guess you are searching for that …

> **[fullScreen() / Reference](https://processing.org/reference/fullscreen_)**
>
> This function is new for Processing 3.0. It opens a sketch using the full size of the computer's display. This function must be the first line in setup(). The size() and fullScreen()\<…

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![ripolas](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@ripolas](https://discourse.processing.org/u/ripolas)\
**Post date:** [March 19, 2024, 5:57pm UTC](https://discourse.processing.org/t/toggling-fullscreen/44121/3 "2024-03-19T17:57:49Z")

</div>

no, sorry if i was not clear in the beggining. I meant that i wanna have like a button or somethign to trigger fullscreen then get back to windowed

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [March 20, 2024, 1:19am UTC](https://discourse.processing.org/t/toggling-fullscreen/44121/4 "2024-03-20T01:19:06Z")

</div>

Would something like this work? It uses _windowResize()_. Hit space bar to get full screen; hit some other key to reset.

```auto
final int _wndW = 400;
final int _wndH = 400;

void setup() {
  size(_wndW, _wndH);
  surface.setResizable(true);
  background(209);
}

void draw() {
}

void keyPressed() {
  if (key == 32) { // space bar
    windowResize(displayWidth, displayHeight);
  } else {
    windowResize(_wndW, _wndH);
  }
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 20, 2024, 1:46pm UTC](https://discourse.processing.org/t/toggling-fullscreen/44121/5 "2024-03-20T13:46:27Z")

</div>

> [@svan](#):
>
> ` windowResize(displayWidth, displayHeight);`

I tried replacing this with `fullScreen()` which doesn’t work.

`fullScreen()` does MORE than `windowResize(displayWidth, displayHeight);` since the position gets also changed.

Can we change the position to 0,0 ?

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [March 20, 2024, 2:22pm UTC](https://discourse.processing.org/t/toggling-fullscreen/44121/6 "2024-03-20T14:22:44Z")

</div>

You might try the [windowMove](https://processing.org/reference/windowMove_.html) method.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [March 20, 2024, 3:31pm UTC](https://discourse.processing.org/t/toggling-fullscreen/44121/7 "2024-03-20T15:31:21Z")

</div>

`Can we change the position to 0,0 ?`  
_setLocation()_ might work:[https://processing.org/reference/setLocation\_.html](https://processing.org/reference/setLocation_.html)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 20, 2024, 7:40pm UTC](https://discourse.processing.org/t/toggling-fullscreen/44121/8 "2024-03-20T19:40:03Z")

</div>

Hi

> [@Processing resizing and changing sketch to and from fullScreen() mid sketch](https://discourse.processing.org/t/processing-resizing-and-changing-sketch-to-and-from-fullscreen-mid-sketch/24005):
>
> This might not sound useful but It took me a some time to get this working so I figured someone might find it useful. Here is the code to be able to resize the sketch and switch it to and from fullscreen while it is running: void setup(){ fullScreen(); surface.setResizable(false); surface.setAlwaysOnTop(true); } // Sets the x and y position of the screen aswell as the width and height void screen(int x, int y, int w, int h){ surface.setLocation(x, y); surface.setSize(w, h); } /…

> [@How do I switch between fullscreen and windowed during the sketch](https://discourse.processing.org/t/how-do-i-switch-between-fullscreen-and-windowed-during-the-sketch/13726):
>
> So as the title says, I want to create a button or something that I can click during a sketch to resize the window from fullscreen to different windowed resolutions like in a game. I’ve experimented with surface.setSize(), surface.setResizable(true) etc, but after a ton of googling I still can’t find a way to switch between windowed and fullscreen during the sketch. Is this a limitation of Processing or am I just missing something here? Any help is greatly appreciated
