# Make window snap in to the borders

**URL:** <https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729>\
**Category:** Coding Questions\
**Created:** [September 7, 2020, 10:18pm UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729 "2020-09-07T22:18:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![LoliProcessor](https://avatars.discourse-cdn.com/v4/letter/l/6a8cbe/32.png) [@LoliProcessor](https://discourse.processing.org/u/LoliProcessor)\
**Post date:** [September 7, 2020, 10:18pm UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729/1 "2020-09-07T22:18:31Z")

</div>

Is there a way to make the window snap in, so being fullscreen basically except for the taskbar?

---

<div class="post-metadata">

**Author:** ![qewer3322](https://avatars.discourse-cdn.com/v4/letter/q/e19adc/32.png) [@qewer3322](https://discourse.processing.org/u/qewer3322)\
**Post date:** [September 9, 2020, 7:36pm UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729/2 "2020-09-09T19:36:52Z")

</div>

```auto
void setup() {
  surface.setSize(300,300);
  surface.setResizable(true);
}

```

this does the trick!

---

<div class="post-metadata">

**Author:** ![LoliProcessor](https://avatars.discourse-cdn.com/v4/letter/l/6a8cbe/32.png) [@LoliProcessor](https://discourse.processing.org/u/LoliProcessor)\
**Post date:** [September 20, 2020, 6:15pm UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729/3 "2020-09-20T18:15:11Z")

</div>

I mean rather in a way that it snaps in on startup, instead of having to click the button of the window myself, is there a way to do that?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [September 20, 2020, 6:46pm UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729/4 "2020-09-20T18:46:45Z")

</div>

One step further, but now we have to discover how to place it top left on startup.

```auto
import java.awt.*;

void setup() {
  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  int screenHeight = screenSize.height;
  int screenWidth = screenSize.width;
  surface.setSize(screenWidth, screenHeight);
  surface.setResizable(true);
}

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [September 20, 2020, 6:58pm UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729/5 "2020-09-20T18:58:07Z")

</div>

Okay, that was easy. Just add:  
surface.setLocation(0, 0);

---

<div class="post-metadata">

**Author:** ![qewer3322](https://avatars.discourse-cdn.com/v4/letter/q/e19adc/32.png) [@qewer3322](https://discourse.processing.org/u/qewer3322)\
**Post date:** [September 21, 2020, 6:19am UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729/6 "2020-09-21T06:19:33Z")

</div>

Processing has screenWidth and screenHeight variables built in as displayWidth and displayHeight:

```auto
void setup() {
  size(displayWidth, displayHeight);
  surface.setResizable(true);
}

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [September 21, 2020, 8:09am UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729/7 "2020-09-21T08:09:33Z")

</div>

@qewer3322  
Thanks, thus they placed it again. It was considered deprecated before. See [here](https://discourse.processing.org/t/built-in-constant-displaywidth-and-displayheight/22404).

---

<div class="post-metadata">

**Author:** ![LoliProcessor](https://avatars.discourse-cdn.com/v4/letter/l/6a8cbe/32.png) [@LoliProcessor](https://discourse.processing.org/u/LoliProcessor)\
**Post date:** [September 22, 2020, 3:47pm UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729/8 "2020-09-22T15:47:23Z")

</div>

I guess that almost does it, except it doesn’t account for taskbar size, it isn’t exactly equivalent to hitting the snap to screen button in windows, but I suppose I 'll just leave it at manually clicking that button every time.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [September 22, 2020, 4:19pm UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729/9 "2020-09-22T16:19:04Z")

</div>

There is also the window height without taskbar.  
But I still adjust it a bit to see the borders.

```auto
import java.awt.*;

void setup() {
  Rectangle winSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
  println(winSize.height);
  println(displayHeight);
  surface.setSize(int(displayWidth*.99), int(winSize.height*.96));
  surface.setResizable(true);
  surface.setLocation(5, 5);
}

```
