# Built in constant: displayWidth and displayHeight

**URL:** <https://discourse.processing.org/t/built-in-constant-displaywidth-and-displayheight/22404>\
**Category:** Processing\
**Created:** [July 6, 2020, 12:11am UTC](https://discourse.processing.org/t/built-in-constant-displaywidth-and-displayheight/22404 "2020-07-06T00:11:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RenanRabelo](https://avatars.discourse-cdn.com/v4/letter/r/ee7513/32.png) [@RenanRabelo](https://discourse.processing.org/u/RenanRabelo)\
**Post date:** [July 6, 2020, 12:11am UTC](https://discourse.processing.org/t/built-in-constant-displaywidth-and-displayheight/22404/1 "2020-07-06T00:11:38Z")

</div>

Is somehow possible to get the display width and height?

I was reading an old forum topic (from 5 years ago) and it said that displayWidth/Height is deprecated.

Is there any method I can use to extract those constants with code?

Thank you

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [July 6, 2020, 12:14am UTC](https://discourse.processing.org/t/built-in-constant-displaywidth-and-displayheight/22404/2 "2020-07-06T00:14:40Z")

</div>

Just use width and height. Not joking.

Var a = width gives you canvas width.

---

<div class="post-metadata">

**Author:** ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)\
**Post date:** [July 6, 2020, 1:02am UTC](https://discourse.processing.org/t/built-in-constant-displaywidth-and-displayheight/22404/3 "2020-07-06T01:02:31Z")

</div>

> [@RenanRabelo](#):
>
> Is there any method I can use to extract those constants with code?

This was covered a while back in [Setting size of display window to a percentage of screen size](https://discourse.processing.org/t/setting-size-of-display-window-to-a-percentage-of-screen-size/22228). If it’s deprecated then there’s a reason for it. During runtime width and height are you friends, you don’t have any use for displayWidth

---

<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:** [July 6, 2020, 1:08am UTC](https://discourse.processing.org/t/built-in-constant-displaywidth-and-displayheight/22404/4 "2020-07-06T01:08:51Z")

</div>

Differences:

```auto
import java.awt.*;

void setup() {
  size(500, 500);
  background(255);
  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  int screenHeight = screenSize.height;
  int screenWidth = screenSize.width;
  println(screenWidth);
  println(screenHeight);
  println(width);
  println(height);
}

```
