Package com.vaadin.ui

Examples of com.vaadin.ui.TextField


        VerticalLayout form = new VerticalLayout();
        form.addStyleName(Bootstrap.Forms.FORM.styleName());
        form.setSpacing(true);
        form.setCaption("Legend");

        TextField email = new TextField("Email address");
        email.setInputPrompt("Enter email");
        form.addComponent(email);

        PasswordField password = new PasswordField("Password");
        password.setInputPrompt("Password");
        form.addComponent(password);
View Full Code Here


        setMainWindow(w);

        final VerticalLayout l = new VerticalLayout();
        l.setWidth("400px");
        l.setHeight("100px");
        l.addComponent(new TextField("This one works fine"));
        TextField t = new TextField();
        t.setRequired(true);
        t.setValue("This one bugs");
        l.addComponent(t);
        w.addComponent(l);

        w.addComponent(new Button("show me the bug",
                new Button.ClickListener() {
View Full Code Here

        final ObjectProperty<Double> property1 = new ObjectProperty<Double>(
                new Double(42.0));

        // A text field that changes its caption
        final TextField tf1 = new TextField(
                "Changing this field modifies only the textfield", property1);
        tf1.addListener(new Property.ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                // This value change event is called twice if the new
                // input value is an integer. The second time is during
                // paint() of AbstractOrderedLayout.

                System.out.println("Value 2 is: " + property1.getValue());

                tf1.setCaption("With caption " + property1.getValue());
            }
        });
        tf1.setImmediate(true);
        mainLayout.addComponent(tf1);

        // ///////////////////////////////////////////////////
        // Totally failing case

        final ObjectProperty<Double> property2 = new ObjectProperty<Double>(
                new Double(42.0));

        // A text field that adds new components
        final TextField tf2 = new TextField(
                "Changing this field modifies the layout - do it twice",
                property2);
        tf2.addListener(new Property.ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                // This value change event is called twice if the new
                // input value is an integer. The second time is during
                // paint() of AbstractOrderedLayout.

                System.out.println("Value 1 is: " + property2.getValue());

                // When this listener is called the second time in paint(), the
                // add operation causes a ConcurrentModificationException
                mainLayout.addComponent(new Label(
                        "Added a component, value is " + property2.getValue()));
            }
        });
        tf2.setImmediate(true);
        mainLayout.addComponent(tf2);

        mainLayout.setSpacing(true);
    }
View Full Code Here

    public void init() {

        final LegacyWindow mainWin = new LegacyWindow("Test app for #20");
        setMainWindow(mainWin);

        final TextField tx = new TextField("Integer");
        mainWin.addComponent(tx);
        tx.setImmediate(true);
        CompositeValidator v = new CompositeValidator();
        v.addValidator(new IntegerValidator("{0} is not a number"));
        v.addValidator(new Validator() {

            private boolean isValid(Object value) {
                try {
                    int i = Integer.parseInt("" + value);
                    if (i < 0) {
                        return false;
                    }
                    return true;
                } catch (NumberFormatException e) {
                    return false;
                }
            }

            @Override
            public void validate(Object value) throws InvalidValueException {
                if (!isValid(value)) {
                    throw new InvalidValueException(value
                            + " is not a non-negative number");
                }
            }
        });
        CompositeValidator v2 = new CompositeValidator(CombinationMode.OR, null);
        v2.addValidator(v);
        v2.addValidator(new Validator() {

            @Override
            public void validate(Object value) throws InvalidValueException {
                if (!"".equals("" + value)) {
                    throw new InvalidValueException("Value is not empty string");
                }
            }
        });
        tx.addValidator(v2);

        final String[] visibleProps = { "required", "invalidAllowed",
                "readOnly", "readThrough", "invalidCommitted",
                "validationVisible" };
        for (int i = 0; i < visibleProps.length; i++) {
            CheckBox b = new CheckBox(visibleProps[i],
                    new MethodProperty<Boolean>(tx, visibleProps[i]));
            b.setImmediate(true);
            mainWin.addComponent(b);
        }

        mainWin.addComponent(new Button("Validate integer",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(
                            com.vaadin.ui.Button.ClickEvent event) {
                        mainWin.showNotification("The field is "
                                + (tx.isValid() ? "" : "not ") + "valid");
                    }
                }));
    }
View Full Code Here

        HorizontalSplitPanel p = new HorizontalSplitPanel();
        p.setSizeFull();
        getMainWindow().setContent(p);

        TextField tf1 = new TextField("Tab 1");
        tf1.setValue("Field 1");
        tf1.setSizeFull();

        Table t = new Table("Table");
        t.addContainerProperty(P1, String.class, "");
        t.setSizeFull();
View Full Code Here

        // MyAccordion accordion = new MyAccordion(new Component[] { table1,
        // table2 }, "Test");

        Label a = new Label("abc123");
        TextField tf = new TextField("A large textfield");
        tf.setHeight("2500px");
        tf.setWidth("2500px");

        TabsAcc tab = new TabsAcc(new Component[] { p, a, tf });
        tab.addListener(this);

        mainLayout.addComponent(sp);
View Full Code Here

        });

        captionField = createTextField("Caption");
        captionField.setInputPrompt("Event name");
        captionField.setRequired(true);
        final TextField whereField = createTextField("Where");
        whereField.setInputPrompt("Address or location");
        final TextArea descriptionField = createTextArea("Description");
        descriptionField.setInputPrompt("Describe the event");
        descriptionField.setRows(3);
        // descriptionField.setRequired(true);
View Full Code Here

        cb.setImmediate(true);
        return cb;
    }

    private TextField createTextField(String caption) {
        TextField f = new TextField(caption);
        f.setNullRepresentation("");
        return f;
    }
View Full Code Here

        t.addContainerProperty(P1, Component.class, null);
        t.addContainerProperty(P2, Component.class, null);
        t.setColumnHeaders(new String[] { "Col1", "Col2" });

        Item i = t.addItem("1");
        i.getItemProperty(P1).setValue(new TextField("abc"));
        i.getItemProperty(P2).setValue(new Label("label"));
        Item i2 = t.addItem("2");
        i2.getItemProperty(P1).setValue(new Button("def"));
        i2.getItemProperty(P2).setValue(new DateField());
View Full Code Here

        final Table table = new Table();
        table.addGeneratedColumn(COL1, new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId,
                    Object columnId) {
                TextField textField = new TextField();
                textField.setWidth("100%");
                return textField;
            }
        });

        table.addItem();
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.