New add-on: SizeReporter

Sometimes, you have to know the size of a component in the browser in pixels. For example, when you want to position a popup below a particular component.

In Vaadin 6, you had to subclass the component to report the size back to the server.

In Vaadin 7, thanks to the new concept of extensions, it is possible to do this without subclassing. The
SizeReporter add-on
is used like this:

 SizeReporter sizeReporter = new SizeReporter(component);

After the layout has been realized in the browser, you can query width and height:

 int width = sizeReporter.getWidth();
 int height = sizeReporter.getWidth();

You cannot query these values immediately when constructing the component. To wait for the
first size report and all subsequent resizes, register a ComponentResizeListener

 sizeReporter.addResizeListener(new ComponentResizeListener() {
     public void sizeChanged(ComponentResizeEvent event) {
         // use event.getWidth() and  event.getHeight()

Nice addon. Easy to use and efficient. Is there a roadmap? Last release in january 13? Is it a dead project?

Is there a similar add-on but that doesn’t need to be used necessarily with resizable components?

Let me explain better. I have a
two columns layout
inside an
and their width is set using expand ratios:

HorizontalLayout layout = new HorizontalLayout();

VerticalLayout col1 = new VerticalLayout();
VerticalLayout col2 = new VerticalLayout();

layout.setExpandRatio(1, col1);
layout.setExpandRatio(5, col5);

Now, col1 is 1/5 of the 100% width of the HorizonalLayout, and col2 is 4/5 of that width. But actually if I want to get the width of col1, how can I do it?

If I just call
I get


(which is the width of the column in % Unit), but I need to obtain the width in pixels programmatically and col1 is not a resizable component, so I guess I cannot do it with the SizeReporter add-on.

Is there a way to do this in Vaadin?

Hi Anton,
I am looking for a resizable Panel component (or) to make a Vaadin Panel Component as resizable Component.How i can achieve this please assist me regarding this Ur help is more appreciated.

Apparently broken and not usable anymore :frowning:
Already the very first line from usage example throws ClassNotFoundException:

SizeReporter sizeReporter = new SizeReporter(mainMenu);

Cannot confirm. Tested using this Add-on in one of my Vaadin 7.5.10 projects and it worked flawlessly. Are you sure the problem is not with the “mainMenu” parameter?

Cannot confirm 7.6.3

Tried to use this add-on inside one of my CustomComponents, when a button is pressed.

public class MyComponent extends CustomComponent {

private final class AnchorBtnClickListener implements ClickListener {
private final Component component;
private static final long serialVersionUID = 7081860874415977274L;

    private AnchorBtnClickListener(Component component) {
        this.component = component;

    public void buttonClick(ClickEvent event) {
        new SizeReporter(detailsBody).addResizeListener(new ComponentResizeListener() {
            private static final long serialVersionUID = -2541921563134977815L;

            public void sizeChanged(ComponentResizeEvent event) {
                System.out.println("H: " + event.getHeight() + " W: " + event.getWidth());

// UI.getCurrent().scrollIntoView(component);


[/code]But unfortunately the SizeReport-Listener is never called. What am I doing wrong?

Yes now i`m trying to use but again i have the same problem like st.huber90

I’m trying the addon right now on my tests and it’s working fine. I had to compile the widgetset in order to get it working, though. Maybe you’ve missed this point.