My goal is to create a horizontal button bar with a variable number of buttons in it. Each button click should open a certain, new gui that is embedded into the extisting one, above the HorizontalLayout.

The first button should always be there. This is the code so far:
public class MainLayout extends VerticalLayout implements PageConfigurator
{
int number = 10;
/**
*
*/
public MainLayout()
{
super();
this.initUI();
this.createButtons();
}
private void createButtons()
{
for(int i = 1; i <= this.number; i++)
{
final Button button = new Button();
button.setText("Button" + i);
button.setHeight("120px");
button.setWidth("120px");
this.horizontalLayout.addComponentAtIndex(i, button);
}
}
@Override
public void configurePage(final InitialPageSettings settings)
{
settings.addLink("shortcut icon", "frontend/images/favicon.ico");
settings.addFavIcon("icon", "frontend/images/favicon256.png", "256x256");
}
/* WARNING: Do NOT edit!<br>The content of this method is always regenerated by the UI designer. */
// <generated-code name="initUI">
private void initUI()
{
this.div = new Div();
this.horizontalLayout = new HorizontalLayout();
this.button = new Button();
this.button.setText("Button");
this.button.setWidth("120px");
this.button.setHeight("120px");
this.horizontalLayout.add(this.button);
this.div.setWidth("100px");
this.div.setHeight("100px");
this.horizontalLayout.setWidthFull();
this.horizontalLayout.setHeight("100px");
this.add(this.div, this.horizontalLayout);
this.setSizeFull();
} // </generated-code>
// <generated-code name="variables">
private Button button;
private HorizontalLayout horizontalLayout;
private Div div;
// </generated-code>
}
My questions:
How do i get a slider in my horizontal layout for the buttons? So that, when there are too many buttons, i can swtich the view.
Later on i would like to update the button bar, so "number" will change at runtime. The button bar should recognize this change and create as many buttons as given. How do i implement the updating?

