Example usage for com.vaadin.ui TextField TextField

List of usage examples for com.vaadin.ui TextField TextField

Introduction

In this page you can find the example usage for com.vaadin.ui TextField TextField.

Prototype

public TextField(ValueChangeListener<String> valueChangeListener) 

Source Link

Document

Constructs a new TextField with a value change listener.

Usage

From source file:com.github.djabry.platform.vaadin.view.LoginView.java

License:Open Source License

private Component buildFields() {
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);//w w w.j  a  v  a2  s .c o m

    userField = new TextField("Username");

    userField.setIcon(FontAwesome.USER);
    userField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    //username.addStyleName(ValoTheme.TEXTFIELD_TINY);

    passwordField = new PasswordField("Password");
    passwordField.setIcon(FontAwesome.LOCK);
    passwordField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    //password.addStyleName(ValoTheme.TEXTFIELD_TINY);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    //signin.addStyleName(ValoTheme.BUTTON_TINY);
    signin.focus();

    fields.addComponents(userField, passwordField, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            loginAction.login(userField.getValue(), passwordField.getValue());
        }
    });
    return fields;
}

From source file:com.github.moscaville.contactsdb.ui.ContactsPanel.java

private void init() {

    setImmediate(true);/*from   w  w  w  . j  a  v a 2  s.co m*/
    firstName = new TextField("First Name");
    vl = new VerticalLayout();
    vl.addComponent(firstName);
    setContent(vl);
}

From source file:com.github.peholmst.springsecuritydemo.ui.LoginView.java

License:Apache License

@SuppressWarnings("serial")
protected void init() {
    final Panel loginPanel = new Panel();
    loginPanel.setCaption(getApplication().getMessage("login.title"));
    ((VerticalLayout) loginPanel.getContent()).setSpacing(true);

    final TextField username = new TextField(getApplication().getMessage("login.username"));
    username.setWidth("100%");
    loginPanel.addComponent(username);/*from w  w  w  .  j a v  a  2  s. c  o  m*/

    final TextField password = new TextField(getApplication().getMessage("login.password"));
    password.setSecret(true);
    password.setWidth("100%");
    loginPanel.addComponent(password);

    final Button loginButton = new Button(getApplication().getMessage("login.button"));
    loginButton.setStyleName("primary");
    // TODO Make it possible to submit the form by pressing <Enter> in any
    // of the text fields
    loginPanel.addComponent(loginButton);
    ((VerticalLayout) loginPanel.getContent()).setComponentAlignment(loginButton, Alignment.MIDDLE_RIGHT);
    loginButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            final Authentication auth = new UsernamePasswordAuthenticationToken(username.getValue(),
                    password.getValue());
            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("Attempting authentication for user '" + auth.getName() + "'");
                }
                Authentication returned = getAuthenticationManager().authenticate(auth);
                if (logger.isDebugEnabled()) {
                    logger.debug("Authentication for user '" + auth.getName() + "' succeeded");
                }
                fireEvent(new LoginEvent(LoginView.this, returned));
            } catch (BadCredentialsException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Bad credentials for user '" + auth.getName() + "'", e);
                }
                getWindow().showNotification(getApplication().getMessage("login.badCredentials.title"),
                        getApplication().getMessage("login.badCredentials.descr"),
                        Notification.TYPE_WARNING_MESSAGE);
            } catch (DisabledException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Account disabled for user '" + auth.getName() + "'", e);
                }
                getWindow().showNotification(getApplication().getMessage("login.disabled.title"),
                        getApplication().getMessage("login.disabled.descr"), Notification.TYPE_WARNING_MESSAGE);
            } catch (LockedException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Account locked for user '" + auth.getName() + "'", e);
                }
                getWindow().showNotification(getApplication().getMessage("login.locked.title"),
                        getApplication().getMessage("login.locked.descr"), Notification.TYPE_WARNING_MESSAGE);
            } catch (Exception e) {
                if (logger.isErrorEnabled()) {
                    logger.error("Error while attempting authentication for user '" + auth.getName() + "'");
                }
                ExceptionUtils.handleException(getWindow(), e);
            }
        }
    });

    HorizontalLayout languages = new HorizontalLayout();
    languages.setSpacing(true);
    final Button.ClickListener languageListener = new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Locale locale = (Locale) event.getButton().getData();
            if (logger.isDebugEnabled()) {
                logger.debug("Changing locale to [" + locale + "] and restarting the application");
            }
            getApplication().setLocale(locale);
            getApplication().close();
        }
    };
    for (Locale locale : getApplication().getSupportedLocales()) {
        if (!getLocale().equals(locale)) {
            final Button languageButton = new Button(getApplication().getLocaleDisplayName(locale));
            languageButton.setStyleName(Button.STYLE_LINK);
            languageButton.setData(locale);
            languageButton.addListener(languageListener);
            languages.addComponent(languageButton);
        }
    }
    loginPanel.addComponent(languages);

    loginPanel.setWidth("300px");

    final HorizontalLayout viewLayout = new HorizontalLayout();
    viewLayout.addComponent(loginPanel);
    viewLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    viewLayout.setSizeFull();
    viewLayout.setMargin(true);

    setCompositionRoot(viewLayout);
    setSizeFull();
}

From source file:com.github.wolfie.sessionguard.SessionguardApplication.java

License:Apache License

@Override
public void init() {
    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);// w w  w .ja  v a  2  s .  c o m
    final Window mainWindow = new Window("Sessionguard Application", mainLayout);

    final int sessionTimeout = ((WebApplicationContext) getContext()).getHttpSession().getMaxInactiveInterval()
            / 60;

    final Label label = new Label(
            "This application has a " + sessionTimeout + "-minute session, with a timeout warning of "
                    + WARNING_PERIOD_MINS + " minutes session time left.");
    mainWindow.addComponent(label);
    setMainWindow(mainWindow);
    final SessionGuard sessionGuard = new SessionGuard();
    sessionGuard.setTimeoutWarningPeriod(WARNING_PERIOD_MINS);
    mainWindow.addComponent(sessionGuard);

    mainWindow.addComponent(new Button("Switch to keepalive", new Button.ClickListener() {
        private static final long serialVersionUID = -4423285632350279761L;
        private boolean keepalive = false;

        public void buttonClick(final ClickEvent event) {
            keepalive = !keepalive;
            sessionGuard.setKeepalive(keepalive);
            event.getButton().setCaption(keepalive ? "Switch to timeout message" : "Switch to keepalive");
        }
    }));

    final TextField warningXhtmlField = new TextField("Change warning XHTML");
    warningXhtmlField.setWidth("100%");
    warningXhtmlField.setValue(sessionGuard.getTimeoutWarningXHTML());
    warningXhtmlField.setImmediate(true);
    warningXhtmlField.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -5236596836421389890L;

        public void valueChange(final ValueChangeEvent event) {
            sessionGuard.setTimeoutWarningXHTML((String) warningXhtmlField.getValue());
            getMainWindow().showNotification("Warning string changed");
        }
    });
    mainWindow.addComponent(warningXhtmlField);

}

From source file:com.gmail.volodymyrdotsenko.cms.fe.vaadin.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    langRepo.findAll().forEach(e -> {
        langSet.add(e.getCode());//w w  w.ja  va2 s .c  o m
    });

    lang = new ComboBox("Language", langSet);

    getPage().setTitle("CMS");

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();

    loginForm.addComponent(userName = new TextField("Username"));
    userName.setRequired(true);
    loginForm.addComponent(passwordField = new PasswordField("Password"));
    passwordField.setRequired(true);
    loginForm.addComponent(rememberMe = new CheckBox("Remember me"));
    loginForm.addComponent(lang);
    lang.setRequired(true);
    lang.setNullSelectionAllowed(false);
    loginForm.addComponent(login = new Button("Login"));
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(e -> {
        login();
    });

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSpacing(true);
    loginLayout.setSizeUndefined();

    if (request.getParameter("logout") != null) {
        loggedOutLabel = new Label("You have been logged out!");
        loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
        loggedOutLabel.setSizeUndefined();
        loginLayout.addComponent(loggedOutLabel);
        loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    }

    loginLayout.addComponent(loginFailedLabel = new Label());
    loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
    loginFailedLabel.setSizeUndefined();
    loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    loginFailedLabel.setVisible(false);

    loginLayout.addComponent(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

    VerticalLayout rootLayout = new VerticalLayout(loginLayout);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
    setContent(rootLayout);
    setSizeFull();

    String currentLang = getLocale().getLanguage();
    if (langSet.contains(currentLang))
        lang.select(currentLang);
    else
        lang.select("en");
}

From source file:com.gnts.gcat.rpt.SyncLogger.java

License:Open Source License

private void buildview() {
    logger.info(//from  w w w .j a v  a 2  s .co m
            "Company ID : " + companyid + " | User Name : " + username + " > " + "Painting Email logger UI");
    // Client text box
    btnAdd.setVisible(false);
    btnAuditRecords.setVisible(false);
    btnEdit.setCaption("View");
    btnEdit.setStyleName("view");

    tfemailId = new TextField("Email Id");
    tfemailId.setReadOnly(false);
    // RAte Changing text box
    tflicError = new TextField("License Error");
    tflicError.setReadOnly(false);
    // product combo box
    tflogMsg = new TextField("Log Message");
    tflogMsg.setReadOnly(false);

    cbsearLogType = new ComboBox("Log Type");
    cbsearLogType.addItem("SYNC");
    cbsearLogType.addItem("ERR");
    cbsearLogType.addItem("EMAIL");

    // productcombo box for search
    cbSearStatus = new GERPComboBox("Sync Status");
    cbSearStatus.addItem("Success");
    cbSearStatus.addItem("Failed");

    cbstatus = new GERPComboBox("Sync Status");
    cbstatus.addItem("Success");
    cbstatus.addItem("Failed");
    cbstatus.setReadOnly(false);

    cblogType = new GERPComboBox("Log Type");
    cblogType.addItem("SYNC");
    cblogType.addItem("ERR");
    cblogType.addItem("EMAIL");

    cblogType.setReadOnly(false);
    // client TExt for Search

    cbcode = new GERPComboBox("Device Code");
    cbcode.setItemCaptionPropertyId("deviceCode");
    loaddevice();

    cbSerDev = new GERPComboBox("Device Code");
    cbSerDev.setItemCaptionPropertyId("deviceCode");
    loaddevice();

    cbemailStatus = new GERPComboBox("Email Status");
    cbemailStatus.addItem("Delivered");
    cbemailStatus.addItem("Failed");
    cbemailStatus.setReadOnly(false);
    // Change start date
    dflogDate = new GERPPopupDateField("Log Date");
    dflogDate.setInputPrompt("Select Date");
    dflogDate.setReadOnly(false);
    // build search layout
    hlSearchLayout = new GERPAddEditHLayout();
    assembleSearchLayout();
    hlSrchContainer.addComponent(GERPPanelGenerator.createPanel(hlSearchLayout));
    //assembleSearchLayout();
    resetFields();
    loadSrchRslt();
}

From source file:com.haulmont.cuba.web.gui.components.presentations.PresentationEditor.java

License:Apache License

protected void initLayout() {
    ThemeConstants theme = App.getInstance().getThemeConstants();

    VerticalLayout root = new VerticalLayout();
    root.setWidthUndefined();/*  ww w. j  av  a  2s. c  om*/
    root.setSpacing(true);
    setContent(root);

    messages = AppBeans.get(Messages.class);

    nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
    nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
    nameField.setValue(getPresentationCaption());
    root.addComponent(nameField);

    autoSaveField = new CheckBox();
    autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
    autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
    root.addComponent(autoSaveField);

    defaultField = new CheckBox();
    defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
    defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
    root.addComponent(defaultField);

    if (allowGlobalPresentations) {
        globalField = new CheckBox();
        globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
        globalField.setValue(!isNew && presentation.getUser() == null);
        root.addComponent(globalField);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidthUndefined();
    root.addComponent(buttons);
    root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);

    Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
    commitButton.addClickListener(event -> {
        if (validate()) {
            commit();
            close();
        }
    });
    buttons.addComponent(commitButton);

    Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
    closeButton.addClickListener(event -> {
        close();
    });
    buttons.addComponent(closeButton);

    nameField.focus();
}

From source file:com.hivesys.dashboard.view.preferences.PreferencesView.java

License:Apache License

public PreferencesView() {

    user = (User) VaadinSession.getCurrent().getAttribute(User.class.getName());

    setSpacing(true);/*from  w  w  w. j  a v  a 2  s.  c om*/
    setMargin(true);

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);

    firstNameField = new TextField("First Name");
    firstNameField.setWidth("50%");
    form.addComponent(firstNameField);

    lastNameField = new TextField("Last Name");
    lastNameField.setWidth("50%");
    form.addComponent(lastNameField);

    titleField = new ComboBox("Title");
    titleField.setInputPrompt("Please specify");
    titleField.addItem("Mr.");
    titleField.addItem("Mrs.");
    titleField.addItem("Ms.");
    titleField.setNewItemsAllowed(true);
    form.addComponent(titleField);

    usernameField = new TextField("Username");
    usernameField.setRequired(true);
    form.addComponent(usernameField);

    sexField = new OptionGroup("Sex");
    sexField.addItem(Boolean.FALSE);
    sexField.setItemCaption(Boolean.FALSE, "Female");
    sexField.addItem(Boolean.TRUE);
    sexField.setItemCaption(Boolean.TRUE, "Male");
    sexField.addStyleName("horizontal");
    form.addComponent(sexField);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    emailField = new TextField("Email");
    emailField.setWidth("50%");
    emailField.setRequired(true);
    form.addComponent(emailField);

    locationField = new TextField("Location");
    locationField.setWidth("50%");
    locationField.setNullRepresentation("");
    form.addComponent(locationField);

    phoneField = new TextField("Phone");
    phoneField.setWidth("50%");
    phoneField.setNullRepresentation("");
    form.addComponent(phoneField);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    websiteField = new TextField("Website");
    websiteField.setInputPrompt("http://");
    websiteField.setWidth("100%");
    form.addComponent(websiteField);

    bioField = new RichTextArea("Bio");
    bioField.setWidth("100%");
    bioField.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bioField);

    Button edit = new Button("Edit", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bioField.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bioField.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

    Label lastModified = new Label("Last modified by you a minute ago");
    lastModified.addStyleName("light");
    footer.addComponent(lastModified);

    fieldGroup = new BeanFieldGroup<>(User.class);
    fieldGroup.bindMemberFields(this);
    fieldGroup.setItemDataSource(user);

    form.setReadOnly(true);
    bioField.setReadOnly(true);

}

From source file:com.hybridbpm.ui.component.chart.color.GaugeBandLayout.java

License:Apache License

public GaugeBandLayout(final BeanFieldGroup<DiagrammePreference> preferences) {
    super(preferences);

    setCaption("Gauge Band Colors");
    setSizeFull();//w  w  w . j  a va  2  s.co  m
    setSpacing(true);
    setMargin(false);

    addBandButton.setIcon(FontAwesome.PLUS);
    addBandButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
    addBandButton.addStyleName(ValoTheme.BUTTON_SMALL);

    bandAdditionButtonFrame.setSpacing(true);
    bandAdditionButtonFrame.addComponent(addBandButton);
    bandAdditionButtonFrame.setComponentAlignment(addBandButton, Alignment.MIDDLE_RIGHT);

    addComponent(bandAdditionButtonFrame);

    addBandButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addBand();
        }
    });

    colorTable.setHeight("100%");
    colorTable.setWidth("100%");
    colorTable.addStyleName(ValoTheme.TABLE_COMPACT);
    colorTable.addStyleName(ValoTheme.TABLE_SMALL);
    colorTable.addStyleName("color-table");

    colorTable.addContainerProperty(Translate.getMessage("colour"), ColorPicker.class, null);
    colorTable.addContainerProperty(Translate.getMessage("start"), TextField.class, null);
    colorTable.addContainerProperty(Translate.getMessage("end"), TextField.class, null);
    colorTable.addContainerProperty("remove", Button.class, null);

    // COLOR COLUMN
    colorTable.addGeneratedColumn(Translate.getMessage("colour"), new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final Property<String> colorProp = tableContainer.getItem(itemId).getItemProperty("color");

            int[] col = ColourUtil.decode(colorProp.getValue());
            ColorPicker picker = new ColorPicker();
            picker.addStyleName("diagramme");
            picker.setPosition(Page.getCurrent().getBrowserWindowWidth() / 2 - 246 / 2,
                    Page.getCurrent().getBrowserWindowHeight() / 2 - 507 / 2);
            picker.setColor(new com.vaadin.shared.ui.colorpicker.Color(col[0], col[1], col[2]));

            picker.addColorChangeListener(new ColorChangeListener() {
                @Override
                public void colorChanged(ColorChangeEvent event) {
                    colorProp.setValue(event.getColor().getCSS());
                    updateDiagramme();
                }
            });
            picker.setWidth("25px");

            return picker;
        }
    });

    // BAND START COLUMN
    colorTable.addGeneratedColumn(Translate.getMessage("start"), new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final Property<Double> startProp = tableContainer.getContainerProperty(itemId, "startValue");

            final ObjectProperty<Double> startValue = new ObjectProperty<Double>(0.0);
            TextField startField = new TextField(startValue);
            //startField.setWidth("60px");
            startField.setSizeFull();
            startField.setNullRepresentation("0");
            startField.addStyleName("tfwb");
            startField.setConvertedValue(startProp.getValue());
            startField.setImmediate(true);

            startValue.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    startProp.setValue((Double) event.getProperty().getValue());
                    updateDiagramme();
                }
            });

            return startField;
        }
    });

    // BAND END COLUMN
    colorTable.addGeneratedColumn(Translate.getMessage("end"), new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final Property<Double> endProp = tableContainer.getContainerProperty(itemId, "endValue");

            final ObjectProperty<Double> endValue = new ObjectProperty<Double>(0.0);
            TextField endField = new TextField(endValue);
            //endField.setWidth("60px");
            endField.setSizeFull();
            endField.setNullRepresentation("0");
            endField.addStyleName("tfwb");
            endField.setConvertedValue(endProp.getValue());
            endField.setImmediate(true);

            endValue.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                    endProp.setValue((Double) valueChangeEvent.getProperty().getValue());
                    updateDiagramme();
                }
            });

            return endField;
        }
    });

    // DELETE BAND COLUMN
    colorTable.addGeneratedColumn("remove", new Table.ColumnGenerator() {

        @Override
        public Object generateCell(Table source, final Object itemId, Object columnId) {

            Button delete = new Button(FontAwesome.TIMES);
            delete.addClickListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    removeBand(itemId);
                }
            });
            delete.setWidth("43px");

            return delete;
        }
    });

    colorTable.setColumnWidth(Translate.getMessage("colour"), 33);
    colorTable.setColumnWidth("remove", 48);
    colorTable.setColumnExpandRatio(Translate.getMessage("start"), 0.5f);
    colorTable.setColumnExpandRatio(Translate.getMessage("end"), 0.5f);

    colorTable.setSortEnabled(false);
    colorTable.setPageLength(0);
    colorTable.setEditable(true);
    colorTable.setImmediate(true);

    addComponent(colorTable);
    setExpandRatio(colorTable, 1f);
    setComponentAlignment(colorTable, Alignment.TOP_LEFT);
}

From source file:com.ies.schoolos.ui.mobile.info.layout.PersonalLayout.java

private void generalInfoLayout() {
    generalGroup = new VerticalComponentGroup();
    generalGroup.setSizeUndefined();/* www .  j a  v  a2 s  .  c  o m*/

    addTab(generalGroup, "", FontAwesome.CHILD);

    peopleIdType = new OptionGroup("", new PeopleIdType());
    peopleIdType.setItemCaptionPropertyId("name");
    peopleIdType.setImmediate(true);
    peopleIdType.setRequired(true);
    peopleIdType.setNullSelectionAllowed(false);
    peopleIdType.setWidth("-1px");
    peopleIdType.setHeight("-1px");
    generalGroup.addComponent(peopleIdType);

    peopleId = new TextField("");
    peopleId.setInputPrompt("");
    peopleId.setImmediate(false);
    peopleId.setRequired(true);
    peopleId.setWidth("-1px");
    peopleId.setHeight("-1px");
    peopleId.setNullRepresentation("");
    peopleId.addValidator(
            new StringLengthValidator("?", 13, 20, false));
    peopleId.addTextChangeListener(new TextChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(TextChangeEvent event) {
            if (event.getText() != null) {
                if (event.getText().length() >= 13) {
                    pSqlContainer.addContainerFilter(new Equal(PersonnelSchema.PEOPLE_ID, event.getText()));
                    if (pSqlContainer.size() > 0) {
                        disableDuplicatePeopleIdForm();
                        Notification.show(
                                "?? ??",
                                Type.WARNING_MESSAGE);
                    } else {
                        enableDuplicatePeopleIdForm();
                    }
                    pSqlContainer.removeAllContainerFilters();
                }
            }
        }
    });
    generalGroup.addComponent(peopleId);

    prename = new NativeSelect("", new Prename());
    //prename.setInputPrompt("??");
    prename.setItemCaptionPropertyId("name");
    prename.setImmediate(true);
    prename.setNullSelectionAllowed(false);
    prename.setRequired(true);
    prename.setWidth("-1px");
    prename.setHeight("-1px");
    //prename.setFilteringMode(FilteringMode.CONTAINS);
    generalGroup.addComponent(prename);

    firstname = new TextField("");
    firstname.setInputPrompt("");
    firstname.setImmediate(false);
    firstname.setRequired(true);
    firstname.setWidth("-1px");
    firstname.setHeight("-1px");
    firstname.setNullRepresentation("");
    generalGroup.addComponent(firstname);

    lastname = new TextField("?");
    lastname.setInputPrompt("?");
    lastname.setImmediate(false);
    lastname.setRequired(true);
    lastname.setWidth("-1px");
    lastname.setHeight("-1px");
    lastname.setNullRepresentation("");
    generalGroup.addComponent(lastname);

    firstnameNd = new TextField("?");
    firstnameNd.setInputPrompt("?");
    firstnameNd.setImmediate(false);
    firstnameNd.setWidth("-1px");
    firstnameNd.setHeight("-1px");
    firstnameNd.setNullRepresentation("");
    generalGroup.addComponent(firstnameNd);

    lastnameNd = new TextField("??");
    lastnameNd.setInputPrompt("??");
    lastnameNd.setImmediate(false);
    lastnameNd.setWidth("-1px");
    lastnameNd.setHeight("-1px");
    lastnameNd.setNullRepresentation("");
    generalGroup.addComponent(lastnameNd);

    firstnameRd = new TextField("");
    firstnameRd.setInputPrompt("");
    firstnameRd.setImmediate(false);
    firstnameRd.setWidth("-1px");
    firstnameRd.setHeight("-1px");
    firstnameRd.setNullRepresentation("");
    generalGroup.addComponent(firstnameRd);

    lastnameRd = new TextField("?");
    lastnameRd.setInputPrompt("?");
    lastnameRd.setImmediate(false);
    lastnameRd.setWidth("-1px");
    lastnameRd.setHeight("-1px");
    lastnameRd.setNullRepresentation("");
    generalGroup.addComponent(lastnameRd);

    nickname = new TextField("");
    nickname.setInputPrompt("");
    nickname.setImmediate(false);
    nickname.setWidth("-1px");
    nickname.setHeight("-1px");
    nickname.setNullRepresentation("");
    generalGroup.addComponent(nickname);

    gender = new OptionGroup("", new Gender());
    gender.setItemCaptionPropertyId("name");
    gender.setImmediate(true);
    gender.setNullSelectionAllowed(false);
    gender.setRequired(true);
    gender.setWidth("-1px");
    gender.setHeight("-1px");
    generalGroup.addComponent(gender);

    religion = new NativeSelect("", new Religion());
    //religion.setInputPrompt("??");
    religion.setItemCaptionPropertyId("name");
    religion.setImmediate(true);
    religion.setNullSelectionAllowed(false);
    religion.setRequired(true);
    religion.setWidth("-1px");
    religion.setHeight("-1px");
    //religion.setFilteringMode(FilteringMode.CONTAINS);
    generalGroup.addComponent(religion);

    race = new NativeSelect("", new Race());
    //race.setInputPrompt("??");
    race.setItemCaptionPropertyId("name");
    race.setImmediate(true);
    race.setNullSelectionAllowed(false);
    race.setRequired(true);
    race.setWidth("-1px");
    race.setHeight("-1px");
    //race.setFilteringMode(FilteringMode.CONTAINS);
    generalGroup.addComponent(race);

    nationality = new NativeSelect("?", new Nationality());
    //nationality.setInputPrompt("??");
    nationality.setItemCaptionPropertyId("name");
    nationality.setImmediate(true);
    nationality.setNullSelectionAllowed(false);
    nationality.setRequired(true);
    nationality.setWidth("-1px");
    nationality.setHeight("-1px");
    //nationality.setFilteringMode(FilteringMode.CONTAINS);
    generalGroup.addComponent(nationality);

    maritalStatus = new NativeSelect("", new MaritalStatus());
    //maritalStatus.setInputPrompt("??");
    maritalStatus.setItemCaptionPropertyId("name");
    maritalStatus.setImmediate(true);
    maritalStatus.setNullSelectionAllowed(false);
    maritalStatus.setRequired(true);
    maritalStatus.setWidth("-1px");
    maritalStatus.setHeight("-1px");
    //maritalStatus.setFilteringMode(FilteringMode.CONTAINS);
    generalGroup.addComponent(maritalStatus);

    aliveStatus = new NativeSelect("?", new AliveStatus());
    //aliveStatus.setInputPrompt("??");
    aliveStatus.setItemCaptionPropertyId("name");
    aliveStatus.setImmediate(true);
    aliveStatus.setNullSelectionAllowed(false);
    aliveStatus.setRequired(true);
    aliveStatus.setWidth("-1px");
    aliveStatus.setHeight("-1px");
    //aliveStatus.setFilteringMode(FilteringMode.CONTAINS);
    aliveStatus.setVisible(false);
    generalGroup.addComponent(aliveStatus);

    birthDate = new PopupDateField("   ?");
    birthDate.setInputPrompt("//");
    birthDate.setImmediate(false);
    birthDate.setRequired(true);
    birthDate.setWidth("-1px");
    birthDate.setHeight("-1px");
    birthDate.setDateFormat("dd/MM/yyyy");
    birthDate.setLocale(new Locale("th", "TH"));
    generalGroup.addComponent(birthDate);

    blood = new NativeSelect("", new Blood());
    //blood.setInputPrompt("??");
    blood.setItemCaptionPropertyId("name");
    blood.setImmediate(true);
    blood.setNullSelectionAllowed(false);
    blood.setRequired(true);
    blood.setWidth("-1px");
    blood.setHeight("-1px");
    //blood.setFilteringMode(FilteringMode.CONTAINS);
    generalGroup.addComponent(blood);

    height = new NumberField("");
    height.setInputPrompt("");
    height.setImmediate(false);
    height.setWidth("-1px");
    height.setHeight("-1px");
    height.setNullRepresentation("");
    generalGroup.addComponent(height);

    weight = new NumberField("?");
    weight.setInputPrompt("?");
    weight.setImmediate(false);
    weight.setWidth("-1px");
    weight.setHeight("-1px");
    weight.setNullRepresentation("");
    generalGroup.addComponent(weight);

    congenitalDisease = new TextField("");
    congenitalDisease.setInputPrompt("");
    congenitalDisease.setImmediate(false);
    congenitalDisease.setWidth("-1px");
    congenitalDisease.setHeight("-1px");
    congenitalDisease.setNullRepresentation("");
    generalGroup.addComponent(congenitalDisease);

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth("100%");
    generalGroup.addComponent(buttonLayout);

    workNext = new Button(FontAwesome.ARROW_RIGHT);
    workNext.setWidth("100%");
    workNext.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            setSelectedTab(workGroup);
        }
    });
    buttonLayout.addComponent(workNext);
}