Absolute layouts

Sometimes we need to place a component in a very specific and exact place of the page. That's the whole point of using AbsoluteLayout. For a GridLayout we have to give the position on the grid, for an AbsoluteLayout we have to give the position on the page. The position must be given using CSS format. For example, to place a component 20 pixels from left and 30 pixels form top, we can do this:

absoluteLayout.addComponent(someComponent, "left: 20px; top: 30px");

Tip

You can use top, left, right, and bottom CSS identifiers to set the position of a component when using AbsoluteLayout. And of course, you can use any CSS unit such as %, in, cm, mm, px, pt, and so on.

Get Vaadin 7 UI Design By Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.