Bug: HorizontalLayout ExpandRatio suppresses Label

Hi,

Maybe there is a bug here…
When exists labels in a horizontal layout and there is another component expanded in the same layout, the label is suppressed.


public class ExampleApp extends Application {

	@Override
	public void init() {
		setMainWindow(new MainWindow());
	}

	class MainWindow extends Window {

		public MainWindow() {
			HorizontalLayout horizontalLayout = new HorizontalLayout();
			horizontalLayout.setWidth("100%");
			horizontalLayout.addComponent(new Button("Button"));
			horizontalLayout.addComponent(new Label("Label"));
			TextField txtField = new TextField();
			txtField.setWidth("100%");
			txtField.setInputPrompt("Texfield expanded");
			horizontalLayout.addComponent(txtField);
			horizontalLayout.setExpandRatio(txtField, 1.0f);
			setContent(horizontalLayout);
		}
	}
}

That’s because all Labels are 100% wide by default and relative sized components with expand ratio of zero will be zero sized (setting the expand ratio on only one widget in the layout sets the remaining expand ratios to zero).

So you need to call Label.setWidth(null) for the label in question in order for it to show up. Or alternatively set an expand ratio for it.

Thanks Jouni, setting label width to null solve my problem!