Manually Resize Popup on internalFrameActivated

I am having this problem where my popups are sporadic in their resizing on the internalFrameActivated event Handler. I am using client tags to store the values that they will resize to. It works great most of the time but if the tag read takes a little bit longer than the allotted time then it doesn’t work initially. If the popup or client refreshes after that it works good again.
I couldn’t figure out how to put it into a function and run invokeLater on it as the size objects weren’t passing through it but is there a way I could nest that into an invokeLater, or something similar, and still have the code run in the correct order?

import time
from java.awt import Dimension

H = system.gui.getParentWindow(event).getComponentForPath('RootContainer').TemplateHeight
W = system.gui.getParentWindow(event).getComponentForPath('RootContainer').TemplateWidth

value = Dimension(width=W,height=H)
system.gui.getParentWindow(event).getComponentForPath('_parent').size = value

Some notes:

  • event.source is the window. No need to call .getParentWindow().

  • Just read the client tags in your script to construct the Dimension.

  • You have used a sleep in the UI thread. That blocks the entire UI–it does not allow anything else in the UI to finish. It’s just frozen. Whatever you think might happen almost certainly won’t. Don’t do it.

Also, consider not doing this in the window. The caller of system.nav.openWindow() is given the window object in return. The caller can then set .size on it.

1 Like

This is the way

  1. That was an oversight of mine, I just used the property finder and that’s what it returned. Thanks

  2. Got it.

  3. I was using sleep to give the tag bindings a chance to initialize as I got some weird errors when I first tried where the internalFrameActivated would run before the bindings initialized. It didn’t work like you said

Edit: grammar

I didn’t know you could set the size on system.nav.openWindow, it seems like I was way overcomplicating this. Thank you.

1 Like