Package com.vaadin.ui

Examples of com.vaadin.ui.TextField


        return 2941;
    }

    @Override
    protected void setup() {
        addComponent(new TextField());
        Button add = new Button("Add an action handler",
                new Button.ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {
View Full Code Here


        // layout.setSizeFull();
        final Label l = new Label(txt);
        l.setContentMode(ContentMode.HTML);
        // l.setWidth("100%");

        TextField tf = new TextField("This is a textField");
        tf.setWidth("100%");

        layout.addComponent(tf);
        layout.addComponent(l);
    }
View Full Code Here

        final CheckBox additionalDescription = new CheckBox(
                "Additional Description");
        final CheckBox tabStop = new CheckBox(
                "Prevent leaving window with Tab key");
        final CheckBox tabOrder = new CheckBox("Change Taborder");
        final TextField prefix = new TextField("Prefix: ");
        final TextField postfix = new TextField("Postfix: ");

        final TextField topTabStopMessage = new TextField(
                "Top Tab Stop Message");
        final TextField bottomTabStopMessage = new TextField(
                "Bottom Tab Stop Message");

        Button simple = new Button("Open Alert Dialog",
                new Button.ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {
                        CssLayout layout = new CssLayout();

                        final Window w = new Window("Sub window", layout);
                        w.center();
                        w.setModal(modal.getValue());
                        w.setAssistiveRole(WindowRole.ALERTDIALOG);
                        w.setAssistivePrefix(prefix.getValue());
                        w.setAssistivePostfix(postfix.getValue());

                        Label description1 = new Label("Simple alert dialog.");
                        layout.addComponent(description1);

                        if (!additionalDescription.getValue()) {
                            w.setAssistiveDescription(description1);
                        } else {
                            Label description2 = new Label(
                                    "Please select what to do!");
                            layout.addComponent(description2);

                            w.setAssistiveDescription(description1,
                                    description2);
                        }

                        w.setTabStopEnabled(tabStop.getValue());
                        w.setTabStopTopAssistiveText(topTabStopMessage
                                .getValue());
                        w.setTabStopBottomAssistiveText(bottomTabStopMessage
                                .getValue());

                        Button close = new Button("Close",
                                new Button.ClickListener() {
                                    @Override
                                    public void buttonClick(ClickEvent event) {
                                        w.close();
                                    }
                                });
                        layout.addComponent(close);
                        Button iconButton = new Button("A button with icon");
                        iconButton.setIcon(new ThemeResource(
                                "../runo/icons/16/ok.png"));
                        layout.addComponent(iconButton);

                        event.getButton().getUI().addWindow(w);
                        iconButton.focus();

                        if (tabOrder.getValue()) {
                            close.setTabIndex(5);
                        }
                    }

                });
        getLayout().addComponent(simple);

        Button complex = new Button("Open Entry Dialog",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        FormLayout form = new FormLayout();

                        final Window w = new Window("Form Window", form);
                        w.center();
                        w.setModal(modal.getValue());
                        w.setAssistivePrefix(prefix.getValue());
                        w.setAssistivePostfix(postfix.getValue());

                        Label description1 = new Label(
                                "Please fill in your data");
                        form.addComponent(description1);

                        if (!additionalDescription.getValue()) {
                            w.setAssistiveDescription(description1);
                        } else {
                            Label description2 = new Label(
                                    "and press the button save.");
                            form.addComponent(description2);

                            w.setAssistiveDescription(description1,
                                    description2);
                        }

                        w.setTabStopEnabled(tabStop.getValue());
                        w.setTabStopTopAssistiveText(topTabStopMessage
                                .getValue());
                        w.setTabStopBottomAssistiveText(bottomTabStopMessage
                                .getValue());

                        TextField name = new TextField("Name:");
                        form.addComponent(name);

                        form.addComponent(new TextField("Address"));

                        Button saveButton = new Button("Save",
                                new Button.ClickListener() {
                                    @Override
                                    public void buttonClick(ClickEvent event) {
                                        w.close();
                                    }
                                });
                        form.addComponent(saveButton);

                        event.getButton().getUI().addWindow(w);
                        name.focus();

                        if (tabOrder.getValue()) {
                            name.setTabIndex(5);
                        }
                    }
                });
        getLayout().addComponent(complex);
View Full Code Here

    @Override
    protected void setup() {

        // some fields with tabindex
        for (int i = 1; i < 4; i++) {
            TextField tf = new TextField();
            tf.setTabIndex(i);
            tf.setInputPrompt("Tab index " + i);
            addComponent(tf);
        }
        // field with tabindex 0
        TextField tf = new TextField();
        tf.setTabIndex(0);
        tf.setInputPrompt("Tab index 0");
        addComponent(tf);

        Button b = new Button("new", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                VerticalLayout layout = new VerticalLayout();
                layout.setMargin(true);
                final Window win = new Window("Subwin", layout);
                layout.setWidth(null);
                win.center();
                win.setClosable(false);
                getMainWindow().addWindow(win);
                layout.addComponent(new Label("SPACE notifies, ESC closes."));

                win.addActionHandler(new Action.Handler() {

                    ShortcutAction esc = new ShortcutAction("Close",
                            ShortcutAction.KeyCode.ESCAPE, null);
                    ShortcutAction spc = new ShortcutAction("Space",
                            ShortcutAction.KeyCode.SPACEBAR, null);

                    @Override
                    public Action[] getActions(Object target, Object sender) {
                        return new Action[] { esc, spc };
                    }

                    @Override
                    public void handleAction(Action action, Object sender,
                            Object target) {
                        if (action == esc) {
                            getMainWindow().removeWindow(win);
                        } else {
                            getMainWindow().showNotification(
                                    action.getCaption());
                        }

                    }

                });

                layout.addComponent(new TextField());
            }

        });
        addComponent(b);
View Full Code Here

        setMainWindow(w);

        GridLayout layout = new GridLayout(2, 2);
        layout.setSpacing(true);

        TextField f1 = new TextField("Non-immediate/Long text field",
                new MethodProperty<Long>(this, "long1"));
        f1.setImmediate(false);
        f1.setNullSettingAllowed(true);
        TextField f2 = new TextField("Immediate/Long text field",
                new MethodProperty<Long>(this, "long2"));
        f2.setImmediate(true);
        f2.setNullSettingAllowed(true);

        layout.addComponent(f1);
        layout.addComponent(f2);

        w.setContent(layout);
View Full Code Here

            }

            VerticalLayout vl = new VerticalLayout();

            // activate & deactivate filtering
            filterString = new TextField("Filter string:", "1");
            vl.addComponent(filterString);

            final CheckBox cb = new CheckBox("Filter on value");
            cb.addListener(new ValueChangeListener() {

                @Override
                public void valueChange(ValueChangeEvent event) {
                    container.removeAllContainerFilters();
                    if (((CheckBox) event.getProperty()).getValue()) {
                        container.addContainerFilter("value", filterString
                                .getValue().toString(), false, false);
                    }
                }
            });
            cb.setImmediate(true);
            vl.addComponent(cb);

            nextLabel = new Label();
            nextLabel.setCaption("Next id: " + nextToAdd);
            vl.addComponent(nextLabel);

            // addItemAt(idx), addItemAfter(selection), addItem()

            final Button addItemButton = new Button("addItem()",
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {
                            container.addItem(new TestBean("addItem() "
                                    + nextToAdd, "value " + nextToAdd));
                            nextToAdd++;
                            nextLabel.setCaption("Next id: " + nextToAdd);
                        }
                    });
            addItemButton.setImmediate(true);
            vl.addComponent(addItemButton);

            final Button addItemAfterButton = new Button("addItemAfter()",
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {
                            Object selection = table.getValue();
                            if (selection == null) {
                                return;
                            }
                            TestBean bean = new TestBean("addItemAfter() "
                                    + nextToAdd, "value " + nextToAdd);
                            Item item = container.addItemAfter(selection, bean);
                            if (item == null) {
                                getMainWindow().showNotification(
                                        "Adding item after " + selection
                                                + " failed");
                            }
                            nextToAdd++;
                            nextLabel.setCaption("Next id: " + nextToAdd);
                        }
                    });
            addItemAfterButton.setImmediate(true);
            vl.addComponent(addItemAfterButton);

            position = new TextField("Position:", "0");
            vl.addComponent(position);

            final Button addItemAtButton = new Button("addItemAt()",
                    new Button.ClickListener() {
                        @Override
View Full Code Here

        }

        VerticalLayout vl = new VerticalLayout();

        // activate & deactivate filtering
        filterString = new TextField("Filter string:", "1");
        vl.addComponent(filterString);

        final CheckBox cb = new CheckBox("Filter");
        cb.addListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                container.removeAllContainerFilters();
                if (((CheckBox) event.getProperty()).getValue()) {
                    container.addContainerFilter("column1", filterString
                            .getValue().toString(), false, false);
                }
            }
        });
        cb.setImmediate(true);
        vl.addComponent(cb);

        nextLabel = new Label();
        nextLabel.setCaption("Next id: " + nextToAdd);
        vl.addComponent(nextLabel);

        // addItemAt(idx), addItemAfter(selection), addItem()

        final Button addItemButton = new Button("addItem()",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        Item item = container.addItem("addItem() " + nextToAdd);
                        if (item != null) {
                            item.getItemProperty("column1").setValue(
                                    "addItem() " + nextToAdd);
                        }
                        nextToAdd++;
                        nextLabel.setCaption("Next id: " + nextToAdd);
                    }
                });
        addItemButton.setImmediate(true);
        vl.addComponent(addItemButton);

        final Button addItemAfterButton = new Button("addItemAfter()",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        Object selection = table.getValue();
                        if (selection == null) {
                            return;
                        }
                        String id = "addItemAfter() " + nextToAdd;
                        Item item = container.addItemAfter(selection, id);
                        if (item != null) {
                            item.getItemProperty("column1").setValue(id);
                            table.setValue(id);
                        } else {
                            getMainWindow().showNotification(
                                    "Adding item after " + selection
                                            + " failed");
                        }
                        nextToAdd++;
                        nextLabel.setCaption("Next id: " + nextToAdd);
                    }
                });
        addItemAfterButton.setImmediate(true);
        vl.addComponent(addItemAfterButton);

        position = new TextField("Position:", "0");
        vl.addComponent(position);

        final Button addItemAtButton = new Button("addItemAt()",
                new Button.ClickListener() {
                    @Override
View Full Code Here

*/
public class ValidatorCaptionTooltip extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        TextField fieldWithError = new TextField();
        int min = 0;
        int max = 100;
        String errorMessage = "Valid value is between " + min + " and " + max
                + ". {0} is not.";
        IntegerRangeValidator validator = new IntegerRangeValidator(
                errorMessage, min, max);
        fieldWithError.setValue("142");

        fieldWithError.addValidator(validator);
        fieldWithError.setConverter(Integer.class);
        fieldWithError.setImmediate(true);

        TextField fieldWithoutError = new TextField();
        fieldWithoutError.addValidator(validator);
        fieldWithoutError.setConverter(Integer.class);
        fieldWithoutError.setValue("42");
        addComponent(fieldWithError);
        addComponent(fieldWithoutError);
    }
View Full Code Here

        form.setFooter(null);
        form.setImmediate(true);
        form.setValidationVisible(true);
        form.setCaption("This is a form");
        form.setDescription("How do you do?");
        final TextField field1 = new TextField("Write here");
        field1.setImmediate(true);
        field1.addValidator(new Validator() {

            @Override
            public void validate(Object value) throws InvalidValueException {
                if (!isValid(value)) {
                    throw new InvalidValueException("FAIL!");
                }
            }

            public boolean isValid(Object value) {
                return field1.getValue().equals("valid");
            }
        });
        form.addField("Field 1", field1);
        layout.addComponent(form);
View Full Code Here

            setFormFieldFactory(new DefaultFieldFactory() {

                @Override
                public TextField createField(Item item, Object propertyId,
                        Component uiContext) {
                    TextField t = new TextField();
                    t.setWidth(100, Unit.PERCENTAGE);
                    t.setHeight(null);
                    t.setCaption((String) propertyId);
                    t.setImmediate(false);
                    return t;
                }
            });

            layout = new GridLayout(2, 1);
View Full Code Here

TOP

Related Classes of com.vaadin.ui.TextField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.