mainWindow.addComponent(tabsheet);
mainWindow.addComponent(panelC);
}
private AbstractComponent getRandomComponent(int caption) {
AbstractComponent result = null;
final int randint = seededRandom.nextInt(7);
switch (randint) {
case 0:
// Label
result = new Label();
result.setCaption("Label component " + caption);
break;
case 1:
// Button
result = new Button();
result.setCaption("Button component " + caption);
break;
case 2:
// TextField
result = new TextField();
result.setCaption("TextField component " + caption);
break;
case 3:
// Select
result = new Select("Select " + caption);
result.setCaption("Select component " + caption);
((Select) result).addItem("First item");
((Select) result).addItem("Second item");
((Select) result).addItem("Third item");
break;
case 4:
// Link
result = new Link("", new ExternalResource("http://www.vaadin.com"));
result.setCaption("Link component " + caption);
break;
case 5:
// Link
VerticalLayout panelLayout = new VerticalLayout();
panelLayout.setMargin(true);
result = new Panel(panelLayout);
result.setCaption("Panel component " + caption);
panelLayout
.addComponent(new Label(
"Panel is a container for other components, by default it draws a frame around it's "
+ "extremities and may have a caption to clarify the nature of the contained components' purpose."
+ " Panel contains an layout where the actual contained components are added, "
+ "this layout may be switched on the fly."));
((Panel) result).setWidth("250px");
break;
case 6:
// Datefield
result = new DateField();
((DateField) result).setStyleName("calendar");
((DateField) result).setValue(new java.util.Date());
result.setCaption("Calendar component " + caption);
break;
case 7:
// Datefield
result = new DateField();
((DateField) result).setValue(new java.util.Date());
result.setCaption("Calendar component " + caption);
break;
}
return result;
}