Package nextapp.echo2.app

Examples of nextapp.echo2.app.TextField


   
    /**
     * Ensure large text is trimmed if MaximumLength property is et.
     */
    public void testMaxLengthTrim() {
        TextField textField = new TextField();
        textField.setMaximumLength(5);
        textField.setText("abcdefghijkl");
        assertEquals("abcde", textField.getText());
    }
View Full Code Here


   
    /**
     * Test property accessors and mutators.
     */
    public void testProperties() {
        TextField textField = new TextField();
        textField.setAlignment(new Alignment(Alignment.LEADING, Alignment.BOTTOM));
        assertEquals(new Alignment(Alignment.LEADING, Alignment.BOTTOM), textField.getAlignment());
        textField.setBorder(TestConstants.BORDER_THICK_ORANGE);
        assertEquals(TestConstants.BORDER_THICK_ORANGE, textField.getBorder());
        textField.setHeight(TestConstants.EXTENT_30_PX);
        assertEquals(TestConstants.EXTENT_30_PX, textField.getHeight());
        textField.setInsets(TestConstants.INSETS_1234);
        assertEquals(TestConstants.INSETS_1234, textField.getInsets());
        textField.setWidth(TestConstants.EXTENT_100_PX);
        assertEquals(TestConstants.EXTENT_100_PX, textField.getWidth());
        textField.setBackgroundImage(TestConstants.BACKGROUND_IMAGE);

        assertEquals(TestConstants.BACKGROUND_IMAGE, textField.getBackgroundImage());
        assertEquals(-1, textField.getMaximumLength());
        textField.setMaximumLength(20);
        assertEquals(20, textField.getMaximumLength());
        textField.setMaximumLength(-1);
        assertEquals(-1, textField.getMaximumLength());
    }
View Full Code Here

        SplitPaneLayoutData splitPaneLayoutData = new SplitPaneLayoutData();
        splitPaneLayoutData.setInsets(new Insets(10));
        testColumn.setLayoutData(splitPaneLayoutData);
        add(testColumn);
       
        TextField textField = new TextField();
        testColumn.add(textField);
       
        Button button = new Button("Test Button");
        testColumn.add(button);
    }
View Full Code Here

        Label label;
       
        label = new Label(Messages.getString("Message.PromptLabel.To"));
        headerGrid.add(label);
       
        toField = new TextField();
        toField.setStyleName("Default");
        toField.setWidth(new Extent(450));
        headerGrid.add(toField);
       
        label = new Label(Messages.getString("Message.PromptLabel.Cc"));
        headerGrid.add(label);
       
        ccField = new TextField();
        ccField.setStyleName("Default");
        ccField.setWidth(new Extent(450));
        headerGrid.add(ccField);
       
        label = new Label(Messages.getString("Message.PromptLabel.Bcc"));
        headerGrid.add(label);
       
        bccField = new TextField();
        bccField.setStyleName("Default");
        bccField.setWidth(new Extent(450));
        headerGrid.add(bccField);
       
        label = new Label(Messages.getString("Message.PromptLabel.Subject"));
        headerGrid.add(label);
       
        subjectField = new TextField();
        subjectField.setStyleName("Default");
        subjectField.setWidth(new Extent(450));
        headerGrid.add(subjectField);
       
        messageField = new TextArea();
View Full Code Here

        add(entryRow);
       
        Label itemLabel = new Label(Messages.getString("PageNavigator.ItemLabel"));
        entryRow.add(itemLabel);
       
        pageField = new TextField();
        pageField.setStyleName("PageNavigator.PageField");
        pageField.setWidth(new Extent(4, Extent.EX));
        pageField.setText("1");
        pageField.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
View Full Code Here

        layoutColumn.add(new Label(new ResourceImageReference("/echo2tutorial/numberguess/TitleBanner.png")));
        layoutColumn.add(statusLabel);
        layoutColumn.add(countLabel);
        layoutColumn.add(promptLabel);
       
        guessEntryField = new TextField();
       
        guessEntryField.setForeground(Color.WHITE);
        guessEntryField.setBackground(Color.BLUE);
        ColumnLayoutData columnLayoutData = new ColumnLayoutData();
        columnLayoutData.setInsets(new Insets(20, 0));
View Full Code Here

    /**
     * @see nextapp.echo2.webcontainer.DomUpdateSupport#renderHtml(nextapp.echo2.webcontainer.RenderContext,
     *      nextapp.echo2.app.update.ServerComponentUpdate, org.w3c.dom.Node, nextapp.echo2.app.Component)
     */
    public void renderHtml(RenderContext rc, ServerComponentUpdate addUpdate, Node parentNode, Component component) {
        TextField textField = (TextField) component;
        String elementId = ContainerInstance.getElementId(textField);

        ServerMessage serverMessage = rc.getServerMessage();
        serverMessage.addLibrary(TEXT_COMPONENT_SERVICE.getId());
       
        Element inputElement = parentNode.getOwnerDocument().createElement("input");
        inputElement.setAttribute("id", elementId);
        if (textField instanceof PasswordField) {
            inputElement.setAttribute("type", "password");
        } else {
            inputElement.setAttribute("type", "text");
        }
        String value = textField.getText();
        if (value != null) {
            inputElement.setAttribute("value", value);
        }
       
        if (textField.isFocusTraversalParticipant()) {
            inputElement.setAttribute("tabindex", Integer.toString(textField.getFocusTraversalIndex()));
        } else {
            inputElement.setAttribute("tabindex", "-1");
        }
       
        String toolTipText = (String) textField.getRenderProperty(TextField.PROPERTY_TOOL_TIP_TEXT);
        if (toolTipText != null) {
            inputElement.setAttribute("title", toolTipText);
        }
       
        Integer maximumLength = (Integer) textField.getRenderProperty(TextField.PROPERTY_MAXIMUM_LENGTH);
        if (maximumLength != null) {
            inputElement.setAttribute("maxlength", maximumLength.toString());
        }

        CssStyle cssStyle = createBaseCssStyle(rc, textField);
View Full Code Here

       
        label = new Label("Server Error URI:");
        label.setStyle(PROMPT_STYLE);
        grid.add(label);
       
        serverErrorUriText = new TextField();
        serverErrorUriText.setStyleName("Default");
        grid.add(serverErrorUriText);
       
        label = new Label("Server Error Message:");
        label.setStyle(PROMPT_STYLE);
        grid.add(label);
       
        serverErrorMessageText = new TextField();
        serverErrorMessageText.setStyleName("Default");
        grid.add(serverErrorMessageText);
       
        label = new Label("Session Expiration URI:");
        label.setStyle(PROMPT_STYLE);
        grid.add(label);
       
        sessionExpirationUriText = new TextField();
        sessionExpirationUriText.setStyleName("Default");
        grid.add(sessionExpirationUriText);
       
        label = new Label("Session Expiration Message:");
        label.setStyle(PROMPT_STYLE);
        grid.add(label);
       
        sessionExpirationMessageText = new TextField();
        sessionExpirationMessageText.setStyleName("Default");
        grid.add(sessionExpirationMessageText);
       
        Button updateButton = new Button("Update ClientConfiguration");
        updateButton.setStyleName("Default");
View Full Code Here

        splitPaneLayoutData = new SplitPaneLayoutData();
        splitPaneLayoutData.setInsets(new Insets(15));
        testColumn.setLayoutData(splitPaneLayoutData);
        add(testColumn);
       
        final TextField textField = new TextField();
        textField.setBorder(new Border(1, Color.BLUE, Border.STYLE_SOLID));
        testColumn.add(textField);
       
        final PasswordField passwordField = new PasswordField();
        passwordField.setBorder(new Border(1, Color.BLUE, Border.STYLE_SOLID));
        testColumn.add(passwordField);
       
        final TextArea textArea = new TextArea();
        textArea.setBorder(new Border(1, Color.BLUE, Border.STYLE_SOLID));
        testColumn.add(textArea);
       
        controlsColumn.addButton("Set Text to Multiple Lines", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String text = "This\nis\na\ntest.";
                textField.getDocument().setText(text);
                passwordField.getDocument().setText(text);
                textArea.getDocument().setText(text);
            }
        });
       
        controlsColumn.addButton("Test HTML Encoding", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String text = "<b>this should NOT be bold</b>";
                textField.getDocument().setText(text);
                passwordField.getDocument().setText(text);
                textArea.getDocument().setText(text);
            }
        });
       
        controlsColumn.addButton("Test Whitespace Encoding", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String text = "   There   are   three   spaces   leading,   trailing,   "
                        + "and   between   each   word.   ";
                textField.getDocument().setText(text);
                passwordField.getDocument().setText(text);
                textArea.getDocument().setText(text);
            }
        });
        controlsColumn.addButton("Toggle ToolTip Text", new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                if (textField.getToolTipText() == null) {
                    textField.setToolTipText("This is a tool tip.");
                    passwordField.setToolTipText("This is a tool tip.");
                    textArea.setToolTipText("This is a tool tip.");
                } else {
                    textField.setToolTipText(null);
                    passwordField.setToolTipText(null);
                    textArea.setToolTipText(null);
                }
            }
        });
        controlsColumn.addButton("Add ActionListener", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.addActionListener(actionListener);
                passwordField.addActionListener(actionListener);
                textArea.addActionListener(actionListener);
            }
        });
        controlsColumn.addButton("Remove ActionListener", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.removeActionListener(actionListener);
                passwordField.removeActionListener(actionListener);
                textArea.removeActionListener(actionListener);
            }
        });
        controlsColumn.addButton("Add DocumentListener", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.getDocument().addDocumentListener(documentListener);
                passwordField.getDocument().addDocumentListener(documentListener);
                textArea.getDocument().addDocumentListener(documentListener);
            }
        });
        controlsColumn.addButton("Remove DocumentListener", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.getDocument().removeDocumentListener(documentListener);
                passwordField.getDocument().removeDocumentListener(documentListener);
                textArea.getDocument().removeDocumentListener(documentListener);
            }
        });

        controlsColumn.addButton("Horizontal Scroll = 0px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setHorizontalScroll(new Extent(0));
                passwordField.setHorizontalScroll(new Extent(0));
                textArea.setHorizontalScroll(new Extent(0));
            }
        });
       
        controlsColumn.addButton("Horizontal Scroll = 100px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setHorizontalScroll(new Extent(100));
                passwordField.setHorizontalScroll(new Extent(100));
                textArea.setHorizontalScroll(new Extent(100));
            }
        });
       
        controlsColumn.addButton("Vertical Scroll = 0px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setVerticalScroll(new Extent(0));
                passwordField.setVerticalScroll(new Extent(0));
                textArea.setVerticalScroll(new Extent(0));
            }
        });
       
        controlsColumn.addButton("Vertical Scroll = 100px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setVerticalScroll(new Extent(100));
                passwordField.setVerticalScroll(new Extent(100));
                textArea.setVerticalScroll(new Extent(100));
            }
        });
       
        controlsColumn.addButton("Change Border (All Attributes)", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Border border = StyleUtil.randomBorder();
                textField.setBorder(border);
                passwordField.setBorder(border);
                textArea.setBorder(border);
            }
        });
        controlsColumn.addButton("Change Border Color", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Border border = textField.getBorder();
                if (border == null) {
                    return;
                }
                border = new Border(border.getSize(), StyleUtil.randomColor(), border.getStyle());
                textField.setBorder(border);
                passwordField.setBorder(border);
                textArea.setBorder(border);
            }
        });
        controlsColumn.addButton("Change Border Size", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Border border = StyleUtil.nextBorderSize(textField.getBorder());
                if (border == null) {
                    return;
                }
                textField.setBorder(border);
                passwordField.setBorder(border);
                textArea.setBorder(border);
            }
        });
        controlsColumn.addButton("Change Border Style", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Border border = StyleUtil.nextBorderStyle(textField.getBorder());
                if (border == null) {
                    return;
                }
                textField.setBorder(border);
                passwordField.setBorder(border);
                textArea.setBorder(border);
            }
        });
        controlsColumn.addButton("Toggle Background Image", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                FillImage backgroundImage = textField.getBackgroundImage();
                if (backgroundImage == null) {
                    textField.setBackgroundImage(Styles.BG_SHADOW_LIGHT_BLUE);
                    passwordField.setBackgroundImage(Styles.BG_SHADOW_LIGHT_BLUE);
                    textArea.setBackgroundImage(Styles.BG_SHADOW_LIGHT_BLUE);
                } else {
                    textField.setBackgroundImage(null);
                    passwordField.setBackgroundImage(null);
                    textArea.setBackgroundImage(null);
                }
            }
        });
        controlsColumn.addButton("Set Foreground", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Color color = StyleUtil.randomColor();
                textField.setForeground(color);
                passwordField.setForeground(color);
                textArea.setForeground(color);
            }
        });
        controlsColumn.addButton("Clear Foreground", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setForeground(null);
                passwordField.setForeground(null);
                textArea.setForeground(null);
            }
        });
        controlsColumn.addButton("Set Background", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Color color = StyleUtil.randomColor();
                textField.setBackground(color);
                passwordField.setBackground(color);
                textArea.setBackground(color);
            }
        });
        controlsColumn.addButton("Clear Background", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setBackground(null);
                passwordField.setBackground(null);
                textArea.setBackground(null);
            }
        });
        controlsColumn.addButton("Change Disabled Border (All Attributes)", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Border border = StyleUtil.randomBorder();
                textField.setDisabledBorder(border);
                passwordField.setDisabledBorder(border);
                textArea.setDisabledBorder(border);
            }
        });
        controlsColumn.addButton("Change Disabled Border Color", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Border border = textField.getDisabledBorder();
                if (border == null) {
                    return;
                }
                border = new Border(border.getSize(), StyleUtil.randomColor(), border.getStyle());
                textField.setDisabledBorder(border);
                passwordField.setDisabledBorder(border);
                textArea.setDisabledBorder(border);
            }
        });
        controlsColumn.addButton("Change Disabled Border Size", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Border border = StyleUtil.nextBorderSize(textField.getDisabledBorder());
                if (border == null) {
                    return;
                }
                textField.setDisabledBorder(border);
                passwordField.setDisabledBorder(border);
                textArea.setDisabledBorder(border);
            }
        });
        controlsColumn.addButton("Change Disabled Border Style", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Border border = StyleUtil.nextBorderStyle(textField.getDisabledBorder());
                if (border == null) {
                    return;
                }
                textField.setDisabledBorder(border);
                passwordField.setDisabledBorder(border);
                textArea.setDisabledBorder(border);
            }
        });
        controlsColumn.addButton("Toggle Disabled Background Image", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                FillImage backgroundImage = textField.getDisabledBackgroundImage();
                if (backgroundImage == null) {
                    textField.setDisabledBackgroundImage(Styles.BG_SHADOW_LIGHT_BLUE);
                    passwordField.setDisabledBackgroundImage(Styles.BG_SHADOW_LIGHT_BLUE);
                    textArea.setDisabledBackgroundImage(Styles.BG_SHADOW_LIGHT_BLUE);
                } else {
                    textField.setDisabledBackgroundImage(null);
                    passwordField.setDisabledBackgroundImage(null);
                    textArea.setDisabledBackgroundImage(null);
                }
            }
        });
        controlsColumn.addButton("Set Disabled Foreground", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Color color = StyleUtil.randomColor();
                textField.setDisabledForeground(color);
                passwordField.setDisabledForeground(color);
                textArea.setDisabledForeground(color);
            }
        });
        controlsColumn.addButton("Clear Disabled Foreground", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setDisabledForeground(null);
                passwordField.setDisabledForeground(null);
                textArea.setDisabledForeground(null);
            }
        });
        controlsColumn.addButton("Set Disabled Background", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Color color = StyleUtil.randomColor();
                textField.setDisabledBackground(color);
                passwordField.setDisabledBackground(color);
                textArea.setDisabledBackground(color);
            }
        });
        controlsColumn.addButton("Clear Disabled Background", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setDisabledBackground(null);
                passwordField.setDisabledBackground(null);
                textArea.setDisabledBackground(null);
            }
        });
        controlsColumn.addButton("Set MaximumLength=10", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setMaximumLength(10);
                passwordField.setMaximumLength(10);
                textArea.setMaximumLength(10);
            }
        });
        controlsColumn.addButton("Clear MaximumLength", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setMaximumLength(-1);
                passwordField.setMaximumLength(-1);
                textArea.setMaximumLength(-1);
            }
        });
        controlsColumn.addButton("Insets -> null", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setInsets(null);
                passwordField.setInsets(null);
                textArea.setInsets(null);
            }
        });
        controlsColumn.addButton("Insets -> 0px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setInsets(new Insets(0));
                passwordField.setInsets(new Insets(0));
                textArea.setInsets(new Insets(0));
            }
        });
        controlsColumn.addButton("Insets -> 5px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setInsets(new Insets(5));
                passwordField.setInsets(new Insets(5));
                textArea.setInsets(new Insets(5));
            }
        });
        controlsColumn.addButton("Insets -> 10/20/30/40px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setInsets(new Insets(10, 20, 30, 40));
                passwordField.setInsets(new Insets(10, 20, 30, 40));
                textArea.setInsets(new Insets(10, 20, 30, 40));
            }
        });
        controlsColumn.addButton("Width -> null", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setWidth(null);
                passwordField.setWidth(null);
                textArea.setWidth(null);
            }
        });
        controlsColumn.addButton("Width -> 500px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setWidth(new Extent(500, Extent.PX));
                passwordField.setWidth(new Extent(500, Extent.PX));
                textArea.setWidth(new Extent(500, Extent.PX));
            }
        });
        controlsColumn.addButton("Width -> 100%", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setWidth(new Extent(100, Extent.PERCENT));
                passwordField.setWidth(new Extent(100, Extent.PERCENT));
                textArea.setWidth(new Extent(100, Extent.PERCENT));
            }
        });
        controlsColumn.addButton("Height -> null", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setHeight(null);
                passwordField.setHeight(null);
                textArea.setHeight(null);
            }
        });
        controlsColumn.addButton("Height -> 300px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setHeight(new Extent(300, Extent.PX));
                passwordField.setHeight(new Extent(300, Extent.PX));
                textArea.setHeight(new Extent(300, Extent.PX));
            }
        });
        controlsColumn.addButton("Toggle Enabled", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                boolean enabled = !textField.isEnabled();
                textField.setEnabled(enabled);
                passwordField.setEnabled(enabled);
                textArea.setEnabled(enabled);
            }
        });
        controlsColumn.addButton("Focus TextField", new ActionListener() {
View Full Code Here

        TableCellRenderer renderer = new TableCellRenderer() {
       
            public Component getTableCellRendererComponent(Table table, Object value, int column, int row) {
                switch (column) {
                case 0:
                    TextField tf = new TextField(new StringDocument(), value.toString(), 30);
                    return tf;
                case 1:
                    SelectField monthField = new SelectField(monthModel);
                    monthField.setSelectedIndex(((Integer) value).intValue());
                    return monthField;
View Full Code Here

TOP

Related Classes of nextapp.echo2.app.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.