Book Image

Vaadin 7 Cookbook

Book Image

Vaadin 7 Cookbook

Overview of this book

Table of Contents (19 chapters)
Vaadin 7 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Showing information about browsers


It could happen that we need browser information in our application. Knowing more about the user can help us with making applications more user-friendly. For example, we could exclude some components in case the browser window is too small or we could display different content to Mac users.

Let's have a look at how to list all the available information about a client web browser.

How to do it...

Carry out the following steps:

  1. First, we get the current page and call the getBrowserWindowHeight and getBrowserWindowWidth methods. As the names of the methods suggest, these two methods return the browser width and height.

    Page page = Page.getCurrent();
    int browserWindowHeight = page.getBrowserWindowHeight();
    int browserWindowWidth = page.getBrowserWindowWidth();
  2. Then, we get the instance of the web browser. The WebBrowser class represents the client's browser and there are many interesting getters there. Let's go through a few of them one by one.

    WebBrowser webBrowser...