Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.squadd.UI; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.DateField; import com.vaadin.ui.FormLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.OptionGroup; import com.vaadin.ui.TextField; /** * * @author SharkNado */ public class PersonalInformationLayout extends FormLayout { private TextField name; private boolean inUse = false; private TextField lastName; private DateField birthDate; private OptionGroup sex; public void setName(TextField name) { this.name = name; } public void setLastName(TextField lastName) { this.lastName = lastName; } public void setBirthDate(DateField birthDate) { this.birthDate = birthDate; } public void setSex(OptionGroup sex) { this.sex = sex; } public TextField getName() { return name; } public TextField getLastName() { return lastName; } public DateField getBirthDate() { return birthDate; } public OptionGroup getSex() { return sex; } public PersonalInformationLayout() { setVisible(false); configureComponents(); buildLayout(); } private void configureComponents() { name = new TextField("Name"); lastName = new TextField("Last Name"); birthDate = new DateField("Birth Date"); sex = new OptionGroup("Sex"); sex.addStyleName("horizontal"); sex.addItems("Male", "Female"); } private void buildLayout() { HorizontalLayout nameLayout = new HorizontalLayout(name); centerAligningComponent(nameLayout, name); HorizontalLayout lastnameLayout = new HorizontalLayout(lastName); centerAligningComponent(lastnameLayout, lastName); HorizontalLayout birthDateLayout = new HorizontalLayout(birthDate); centerAligningComponent(birthDateLayout, birthDate); HorizontalLayout sexLayout = new HorizontalLayout(sex); centerAligningComponent(sexLayout, sex); addComponents(nameLayout, lastnameLayout, birthDateLayout, sexLayout); } private void centerAligningComponent(HorizontalLayout where, Component what) { where.setSizeFull(); where.setComponentAlignment(what, Alignment.TOP_CENTER); } public boolean isInUse() { return inUse; } public void setInUse(boolean inUse) { this.inUse = inUse; } }