Package com.vaadin.ui

Examples of com.vaadin.ui.TextField


    @Override
    protected void setup() {
        final HorizontalLayout hl = new HorizontalLayout();
        autoWideWindow = new Window("Dialog - width by contents", hl);
        hl.setSizeUndefined();
        hl.addComponent(new TextField("Field 1"));
        hl.addComponent(new TextField("Field 2"));
        hl.addComponent(new Button("Add", new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                hl.addComponent(createRemoveButton());

            }

        }));

        getMainWindow().addWindow(autoWideWindow);

        {
            VerticalLayout vl = new VerticalLayout();
            vl.setMargin(true);
            Window dialog = new Window("Dialog - undefined width", vl);
            vl.addComponent(new TextField("Field 1"));

            TextField tf2 = new TextField("Field 2");
            tf2.setWidth("500px");
            vl.addComponent(tf2);
            vl.addComponent(new Button("Ok"));

            dialog.center();
            getMainWindow().addWindow(dialog);
View Full Code Here


        w.getContent().setHeight("2000");
        w.addComponent(layout);

        layout.addComponent(new Label(
                "This should NOT get stuck when scrolling down"));
        layout.addComponent(new TextField("This should not get stuck either..."));

        VerticalLayout ol = new VerticalLayout();
        ol.setHeight("1000");
        ol.setWidth("200");
        w.addComponent(ol);
View Full Code Here

    }

    public FormLayout createFormLayout() {
        FormLayout layout = new FormLayout();
        final TextField textField = new TextField("TextField");
        textField.setEnabled(false);
        layout.addComponent(textField);

        final ComboBox combobox = new ComboBox("Combobox");
        combobox.setEnabled(false);
        layout.addComponent(combobox);

        final NativeSelect nativeSelect = new NativeSelect("NativeSelect");
        nativeSelect.setEnabled(false);
        layout.addComponent(nativeSelect);

        final CheckBox checkBox = new CheckBox("Checkbox");
        checkBox.setEnabled(false);
        layout.addComponent(checkBox);

        layout.addComponent(new Button("Toggle components enabled",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        combobox.setEnabled(!combobox.isEnabled());
                        textField.setEnabled(!textField.isEnabled());
                        checkBox.setEnabled(!checkBox.isEnabled());
                        nativeSelect.setEnabled(!nativeSelect.isEnabled());
                    }
                }));
        return layout;
View Full Code Here

    }

    public void testChangeReadOnlyFieldLocale() {
        VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null));

        TextField tf = new TextField("salary");
        tf.setLocale(new Locale("en", "US"));
        ObjectProperty<Integer> ds = new ObjectProperty<Integer>(123456789);
        ds.setReadOnly(true);
        tf.setPropertyDataSource(ds);
        assertEquals((Integer) 123456789, ds.getValue());
        assertEquals("123,456,789", tf.getValue());
        tf.setLocale(new Locale("fi", "FI"));
        assertEquals((Integer) 123456789, ds.getValue());
        assertEquals("123" + FORMATTED_SPACE + "456" + FORMATTED_SPACE + "789",
                tf.getValue());
    }
View Full Code Here

        return TextField.class;
    }

    @Override
    protected void initializeComponents() {
        TextField tf;

        tf = createTextField("TextField 100% wide");
        tf.setWidth("100%");
        addTestComponent(tf);

        tf = createTextField(null, "TextField 100% wide, no caption");
        tf.setWidth("100%");
        addTestComponent(tf);

        tf = createTextField("TextField auto wide");
        addTestComponent(tf);

        tf = createTextField("TextField with input prompt");
        tf.setInputPrompt("Please enter a value");
        addTestComponent(tf);

        tf = createTextField("100px wide textfield");
        tf.setWidth("100px");
        addTestComponent(tf);

        tf = createTextField("150px wide, 120px high textfield");
        tf.setWidth("150px");
        tf.setHeight("120px");
        addTestComponent(tf);

        tf = createTextField("50px high textfield");
        tf.setHeight("50px");
        addTestComponent(tf);

        tf = createTextField(null, "No caption");
        addTestComponent(tf);

        tf = createTextField(null, "No caption and input prompt");
        tf.setInputPrompt("Enter a value");
        addTestComponent(tf);

    }
View Full Code Here

    }

    public void testNumberDoubleConverterChange() {
        final VaadinSession a = new AlwaysLockedVaadinSession(null);
        VaadinSession.setCurrent(a);
        TextField tf = new TextField() {
            @Override
            public VaadinSession getSession() {
                return a;
            }
        };
        NumberBean nb = new NumberBean();
        nb.setNumber(490);

        tf.setPropertyDataSource(new MethodProperty<Number>(nb, "number"));
        assertEquals(490, tf.getPropertyDataSource().getValue());
        assertEquals("490", tf.getValue());

        Converter c1 = tf.getConverter();

        tf.setPropertyDataSource(new MethodProperty<Number>(nb, "number"));
        Converter c2 = tf.getConverter();
        assertTrue(
                "StringToInteger converter is ok for integer types and should stay even though property is changed",
                c1 == c2);
        assertEquals(490, tf.getPropertyDataSource().getValue());
        assertEquals("490", tf.getValue());

    }
View Full Code Here

        addTestComponent(tf);

    }

    private TextField createTextField(String caption, String value) {
        TextField tf = new TextField(caption);
        tf.setValue(value);

        return tf;
    }
View Full Code Here

        final FormLayout fl = new FormLayout();
        addComponent(fl);

        for (int i = 20; i-- > 0;) {
            fl.addComponent(new TextField());
        }

        final Table table = new Table();
        table.setSelectable(true);
        table.addContainerProperty("item", String.class, "");
View Full Code Here

    }

    @Test
    public void testNullConverter() {
        TextField tf = new TextField("foo");
        tf.setConverter(new StringToIntegerConverter());
        tf.setPropertyDataSource(new ObjectProperty<Integer>(12));
        tf.setConverter((Converter) null);
        try {
            Object v = tf.getConvertedValue();
            System.out.println(v);
            Assert.fail("Trying to convert String -> Integer should fail when there is no converter");
        } catch (ConversionException e) {
            // ok, should happen when there is no converter but conversion is
            // needed
View Full Code Here

        FIRST_VALUE, VALUE, THE_LAST_VALUE;
    }

    @Override
    protected void setup(VaadinRequest request) {
        final TextField tf = new TextField();
        tf.addValueChangeListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                if (tf.isValid()) {
                    log(tf.getValue() + " (valid)");
                } else {
                    log(tf.getValue() + " (INVALID)");
                }
            }
        });

        tf.setPropertyDataSource(new ObjectProperty<Enum>(MyEnum.FIRST_VALUE));
        addComponent(tf);
    }
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.