How to resize image in a container and maintain aspect ratio

I have an image in a Container that I would like to resize along with the container. The Image component itself actually seems to be resizing fine based on seeing that the Border of the Image component is resizing with the Border of the Container. However, the actual jpg in the Image Path does not rescale/resize with the Image container. Is there a way to accomplish this?

Both the Layout for the Container and Image are Relative/Maintain Aspect Ratio/Center.

Some more information is that the image is stored in the SQL Server database and loaded into the Image at runtime via the script in a dropdown selection shown below. You can see in the script that I was using getScaledInstance at one point.

I had also thought of trying to get the height and width of the Container on propertyChange and then manually resize the image icon, but I could not see how to get the size (height, width) of the Container.

[code]
if event.propertyName == ‘selectedValue’:
# Get the selected String Value of the Dropdown.
imageID = event.source.selectedValue

#---------------------------------------------------------------------------------------------------
# Hide the Image control in case there is no image in the database for drop-down selection.
event.source.parent.getComponent('ContainerMap').getComponent("Image").visible = 0 
from javax.swing import ImageIcon
# Get the binary image from the database.
blob = system.db.runScalarQuery("SELECT StoredImage FROM Images WHERE ImageID = '%s'"%(imageID))
# If an image is stored in the database (blob > 0) then display the image.
if blob > 0:
   icon = ImageIcon(blob)
   img= icon.getImage()
   #resizedImg= img.getScaledInstance(900,700, 1)
   #newIcon= ImageIcon(resizedImg)	 
   newIcon= ImageIcon(img)	

   event.source.parent.getComponent('ContainerMap').getComponent("Image").setIcon(newIcon)
   event.source.parent.getComponent('ContainerMap').getComponent("Image").visible = 1[/code]

There is a property of the Image component called ‘Stretch Mode’ that you can set to No Stretch, Bounds, % Bounds, or Parameters. Just pick the one you want and it will redraw as it’s re-sized.

If you really need to get the width or height of a component, you can call component.getWidth() and component.getHeight(). You can find out more about them in the Java docs.