How to lock the resolution in JAVA2D rendering environment

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!

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

Not sure exactly what you are hoping to achieve but you might want to look at setResizable

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

  1. scale 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
1 Like