Popup window and Window size and location problem

To resize it dynamically based on the parent window's session size, you will just have to get the parent window height, create a dimension, and adjust the popup's size. Integrating that into your existing code will look like this:

from java.awt import Dimension

# Get the parent window
parentWindow = system.gui.getParentWindow(event)

# Get the parent width and height
parentWidth = parentWindow.width
parentHeight = parentWindow.height

# Get and open the popup
popup = system.nav.openWindow('CM/Popup')

# Calculate the desired coordinates for the popup's position
x = parentWidth - popup.width # Far right of Main Window
y = 0 # Top of Main Window

# Position and resize the popup
popup.setLocation(x, y)
popup.setPreferredSize(Dimension(popup.width, parentHeight))
popup.setSize(Dimension(popup.width, parentHeight))