# How to lock the resolution in JAVA2D rendering environment

**URL:** https://discourse.processing.org/t/how-to-lock-the-resolution-in-java2d-rendering-environment/45936
**Category:** Coding Questions
**Created:** [March 9, 2025, 7:45am UTC](https://discourse.processing.org/t/how-to-lock-the-resolution-in-java2d-rendering-environment/45936 "2025-03-09T07:45:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cola](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@cola](https://discourse.processing.org/u/cola)
#### Post date: [March 9, 2025, 7:45am UTC](https://discourse.processing.org/t/how-to-lock-the-resolution-in-java2d-rendering-environment/45936/1 "2025-03-09T07:45:20Z")

</div>

Hello everyone! I am doing resolution adaptation in the JAVA2D environment, hoping that the UI interface will be distorted when switching screens. How to lock the resolution in JAVA2D rendering environment？ Thanks!

```auto
public void setup(){
  size(2400, 1200, JAVA2D);
}

```

---

<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 9, 2025, 10:03am UTC](https://discourse.processing.org/t/how-to-lock-the-resolution-in-java2d-rendering-environment/45936/2 "2025-03-09T10:03:44Z")

</div>

Not sure exactly what you are hoping to achieve but you might want to look at [setResizable](https://processing.org/reference/setResizable_.html)

If you want to distort the display to ‘fit’ the new size I can think of 2 alternatives

1. [scale](https://processing.org/reference/scale_.html) change the scale based on the previous and the new display size
2. in the draw method all positions and sizes used for draw commands e.g. line, rect, ellipse etc. are expressed as a proportion of the display width and height
