Unscrollable Sub Window

I am developing a small application that shows thumbnails inside a table with links (buttons) beneath them. When the user clicks on the button, a sub window opens with the large image in it. I am setting the sub window’s size as undefined, so that it fits the image contained. The problem is that when the image exceeds the dimensions of the screen, no scroll bars show up, which leaves me with only a visible portion of the image.

I tried some workarounds with no success.

  • I made the sub window scrollable.
  • I tried checking the size of the window and compare it with that of the main window.
  • I set the sub window’s size to full, which provides scrollbars for large images, but doesn’t fit small images.

Is there anyway to make a sub window of undefined size scrollable if its contents exceed the dimensions of the screen?

Here are the relevant parts of the code of my sub window class.

public PhotoWindow(int studentCode,Application app){
		setModal(true);
		setScrollable(true);
		setWidth("");	//Width is undefined; fits the photo.
		setHeight("");	//Height is undefined; fits the photo.
		getContent().setSizeUndefined();

		Embedded embeddedImage=new Embedded("",imageResource);
		addComponent(embeddedImage);
	}

Hi,

As far as I see, setScrollable(true) only sets that
programmatic
scrolling with setScrollLeft() and setScrollTop() is enabled. Panels are by default not scrollable with the methods, while sub-windows are. This is actually very different from what the JavaDoc for the setScrollable() says, and I don’t know why. It could be obsolete API. This might beg for a ticket of some sort.

For scrollbars to show up, the sub-window must have a defined (fixed or relative) size and the root layout must have either undefined or fixed size in the desired direction. If that size is bigger than the size of the content area of the sub-window, scrollbars will appear automatically. See for example
this example
. It’s the same as for Panel, as shown in
this example
.

Scrollbars are explained at least in the Knowledge Base article
#217: How do I add scroll bar or bars to a component?
(Pro Account required).