Disable Window Scrolling

I’m trying to disable scrolling for a modal window I’ve created but I must not be doing it properly or there’s a bug…probably the former.

Here’s my whole application class:


public void init() {
		Window mainWindow = new Window("Window Scrolling Application");
		Button button = new Button("Open Window");
		
		final Window newWindow = buildWindow();
		
		button.addListener(new ClickListener() {
			
			public void buttonClick(ClickEvent event) {
				event.getComponent().getWindow().addWindow(newWindow);
			}
		});
		
		mainWindow.addComponent(button);
		setMainWindow(mainWindow);
	}

	private Window buildWindow() {
		Window window = new Window("Test Scrolling");
		VerticalLayout vl = new VerticalLayout();
		vl.setHeight("500px");
		vl.addComponent(new Button());
		vl.addComponent(new Button());
		window.addComponent(vl);
		window.setScrollable(false);
		window.setModal(true);
		return window;
	}

When the modal window pops up, and I adjust the size of the window, scrollbars eventually appear and I’m able to scroll around in the window. I’m trying to suppress the scrollbars, which is what I thought:


window.setScrollable(false);

would do…

Any ideas?

I have to say, the setScrollable() is a rather odd method as it seems to control whether or not you can scroll the window (or Panel to be exact) programmatically with setScrollLeft() and setScrollTop(). Its purpose is rather vague, I must say, probably something very technical that perhaps should not even be in the API. You could make a ticket to make the meaning of the method more sensible or at least ask to make better JavaDocs to explain it better.

You could

  1. make a layout that doesn’t mind about resizing by using setFullSize() for the root layout of the window, etc.
  2. use setResizeable(false) to disable resizing
  3. prevent scroll bars from CSS with “.v-window-contents > div {overflow: hidden !important;}”, but I’m not sure it’s a good idea.