Browser Window Resize Events

The Page class allows you to register a listener for events that affect the web page and the browser window in which the Vaadin UI resides. The Page instance corresponding to a given UI is accessed by the getPage() method of the UI.

Example: Accessing the browser window size and adding a size-change listener.

Java

  1. Page page = UI.getCurrent().getPage();
  2. page.addBrowserWindowResizeListener(
  3. event -> Notification.show("Window width="
  4. + event.getWidth()
  5. + ", height=" + event.getHeight()));