Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In a Processing sketch, can I control the position of the display window?

I hope that this is the correct site for this question, apologies if not.

In a Processing sketch, can I control the initial position of the display window? The size() function that must be called first allows only the width and height to be specified.

This has occurred as a likely problem now I am starting to use the G4P (GUI for Processing) library, where the position of a GWindow() has position parameters, but they do not seem to be relative to the main display window but to the whole monitor screen, and I want the extra windows to appear within the main window. This will especially matter when I want to transfer use of the program from my desktop (monitor 1280 by 1024 pixels) to my laptop (1280 by 800 pixels).

like image 257
Harry Weston Avatar asked Jan 09 '23 04:01

Harry Weston


1 Answers

Assuming you're talking about Java mode, then you have access to a variable called frame.

However, the frame variable does not seem to be available until after the setup() function finishes, so you have to access it after that. This works for me:

boolean frameMoved = false;

void setup() {
  size(500, 500);
}

void draw() {

  if(!frameMoved){
    frame.setLocation(100, 100);
    frameMoved = true;
  }

  background(0);
}

There is probably a smarter way to do this, but it works for me.

like image 166
Kevin Workman Avatar answered Jan 26 '23 11:01

Kevin Workman