Identify current monitor's (multiple) client size

I have a single client with multiple desktops-window opened in some monitors. I want to get the size (w,h) of each monitor, depending of the current monitor where the window appears.
I’ve been testing some options but I don’t get into the correct one. I used system.gui.getScreens(), but I need to identify in a window script which is the index of the current monitor where this windows it’s been shown, but I don’t know how.
I also tried with:

from javax.swing import JFrame, SwingUtilities
window = system.gui.getParentWindow(event)
frame = SwingUtilities.getAncestorOfClass(JFrame, window)
width=frame.width
height=frame.height

But I get the error
image

also tried
import java.awt
gd=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
width = gd.getDisplayMode().getWidth()
height = gd.getDisplayMode().getHeight()

But this one only gives the default monitor info. I wish .getCurrentScreen() exists…

I also some other codes but I get errors or not desired behavior.

I need some advices please!!

Have you tried system.gui.getScreenIndex() ?

1 Like

I not sure how to use it. Please tell me how
The documentation suggest this output is the index where the function was called. But where show I place the function on the root container of the window itself and which event handler show I use to trigger when ever the client moves between monitors?

ohh, now I understand, thanks for your suggest