Cancel the setSizeFull effect on component?

Hi,
I want to cancel a
setSizeFull
effect on a component using a button ClickListener?
tell me explain:

[code]

//my vertical layout
VerticalLayout vl = new VerticalLayout();

    vl.addComponent(grid);
    [b]

vl.setSizeFull();
[/b]

// my button listener

topcenter.addListener(new ClickListener(){

		@Override
		public void buttonClick(ClickEvent event) {
			//[b]

wants to cancel the “vl.setSizeFull();” here
[/b]

		}} );

[/code][i]

[/i]

how can I do this?
Regards[b]

[/b]

The method setSizeFull() simply sets both the height and the width of a component to 100%. The default values for component size vary by component, for a VerticalLayout they are 100% width and undefined height.

Therefore, you can set the height of the layout to be undefined to reset the layout size to its defaults. This can be done e.g. with

vl.setHeight(Sizeable.SIZE_UNDEFINED, Sizeable.UNITS_PIXELS);

thank you Henri,
I used it and it works !
but what’s the difference between:


vl.setHeight(Sizeable.SIZE_UNDEFINED, Sizeable.UNITS_PIXELS);

and:


vl.setSizeUndefined();

The former only affects the height but lets the component fill the available width, the latter makes both the height and the width undefined (i.e. defined by the content).

Another alternative in your case would be

vl.setSizeUndefined();
vs.setWidth("100%");

Hi,
based on:

I used this approach to display the Vertical Scroll Bar in my main vertical layout that contains other components and there is the result:
11249.png

Assuming you corrected the typo in my previous post (vl instead of vs), I suspect the issue is with some other layout - maybe even one that you have not added explicitly but is there automatically, such as the default VerticalLayout as the contents of a Window.

You could first try to add the “?debug” parameter to your URL and click “Analyze layouts” in the debug window. One common issue is using only relative width (e.g. 100%) components inside a layout of undefined width (i.e. width defined by its contents) - in that case, nothing tells the undefined size layout how wide it should really be. The most common correction is to change the size of all the containing undefined size layouts to 100% or some other defined value.

If “Analyze layouts” does not report any layout problems, it would be useful to know more about the layout structure that exhibits the issue.