I'm trying to make the process of placing popup windows faster.
The popups are configured from UTD.
The idea is being able to move the popup to where I want it to be, and then clicking a button to start a script that saves the position.
I however can't seem to find a way to read the coordinates of the popup window.
I don't know if I understood your question but if you need get X and y position of popup,
you must use
event.clientY
event.clientX
That was quick. I think you understood my question correct.
I've just closed the project for the day, I'll report back when I get a chance to test it.
The popup's own window object has coordinates, as it is, under the hood, just another Java Swing subclass.
Each window has event handlers that could be used for this purpose. For saving the last popup location, I would probably try internalFrameDeactivated or perhaps internalFrameClosing. There is also a visionWindowClosed event, but I'm not confident that the coordinates would not be null at that event.
The location properties can be accessed from any of those event handlers in this way:
x = event.source.x
y = event.source.y
Setting the location of a popup is not typically set from the popup itself, but rather from the event that opened the popup.
Example:
# Get and simultaneously open the popup
popup = system.nav.openWindow('Path/To/Popup')
x, y = # Get these coordinates from wherever they have been saved
# Move the popup to the desired location
popup.setLocation(x, y) # This happens too fast to be noticed by the user
Actually, it isn't a matter of "too fast". Swing is single-threaded, so Swing doesn't get a chance to start drawing the newly opened window between the scripted open and the change of location.
Thank you for the replies.
After getting back into the office and doing a bit of trial and error I made it work just like I had hoped.