Code for foreground window

Hi there is a code to put window in the foreground, like: SetWindowsPos (0)?

Is this what you are looking for? This put always puts the window on top.

import javax.swing.*;
import processing.awt.*;
  JFrame window;
void setup() {
  window=(JFrame) ((PSurfaceAWT.SmoothCanvas)this.getSurface().getNative()).getFrame();
  window.setAlwaysOnTop(true);
}
void draw(){}

Or are you looking to change the location of the window?

import javax.swing.*;
import processing.awt.*;
  JFrame window;
void setup() {
  window=(JFrame) ((PSurfaceAWT.SmoothCanvas)this.getSurface().getNative()).getFrame();
  window.setLocation(0,0);
}
void draw(){}
1 Like

Perfect, it works great, thanks you are the best.

No problem! For manipulating windows looking up the same thing for JFrames might be worth a shot as JFrames allow for very much manipulation like hiding or resizing. Also Processing uses them for it’s window too.

1 Like

An easier way to do it without imports and that AWT stuff is simply,

surface.setAlwaysOnTop(true);

same goes for setting the location

surface.setLocation(0,0);

heres a list of the surface options PSurfaceNone

Outstanding Mikey83 was what I was looking for, thank you, you are number one

1 Like

Glad to help mate, happy coding

Thanks, sorry if I take advantage, is there also an instruction to minimize on the traybar and opposite?

Not that i have seen, maybe with JFrame as@NumericPrime suggested for controlling the window.
Using surface you could use

surface.setVisible(false);

that will hide the window, then use

surface.setVisible(true);

to make it visible again, bout the closest ive come

Thanks, I had already tried with “surface.setVisible (true);” but it doesn’t work, I will try, as recommended, to use the instructions inserted by @NumericPrime.

P.S. Sorry my english, but i’m italian.

1 Like

Solved with - window.setState(window.NORMAL); -
Thank you all for your cooperation.

1 Like