Example usage for com.google.gwt.user.client.ui TextBox setMaxLength

List of usage examples for com.google.gwt.user.client.ui TextBox setMaxLength

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui TextBox setMaxLength.

Prototype

public void setMaxLength(int length) 

Source Link

Document

Sets the maximum allowable length of the text box.

Usage

From source file:pl.morgwai.sample.gwtGuiceHibernate.gwtPresentation.UserSearchEntryPoint.java

License:Apache License

@Override
public void onModuleLoad() {
    serviceFactory = GWT.create(RequestBuilderFactory.class);
    EventBus eventBus = new SimpleEventBus();
    serviceFactory.initialize(eventBus);

    RootPanel createUserPanel = RootPanel.get(CREATE_USER_PANEL_ID);

    final TextBox newUserNameTextBox = new TextBox();
    newUserNameTextBox.setName("newUserName");
    newUserNameTextBox.setMaxLength(64);
    newUserNameTextBox.setText(messages.newUserNamePrompt());
    createUserPanel.add(newUserNameTextBox);

    final Button createUserButton = new Button(messages.createUserButtonLabel());
    createUserPanel.add(createUserButton);
    createUserButton.addClickHandler(new ClickHandler() {
        @Override//from ww w .j  a  v a2 s. c  o m
        public void onClick(ClickEvent event) {
            createUserButton.setEnabled(false);
            createUser(newUserNameTextBox.getText());
            newUserNameTextBox.setText("");
        }
    });

    createUserDialogBox = new DialogBox();
    Button closeButton = new Button(messages.closeButtonLabel());
    createUserDialogBox.add(closeButton);
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            createUserDialogBox.hide();
            createUserButton.setEnabled(true);
        }
    });

    RootPanel userSearchPanel = RootPanel.get(USER_SEARCH_PANEL_ID);

    final TextBox searchNameTextBox = new TextBox();
    searchNameTextBox.setName("searchUserName");
    searchNameTextBox.setAlignment(TextAlignment.LEFT);
    searchNameTextBox.setMaxLength(64);
    searchNameTextBox.setText(messages.searchUserNamePrompt());
    userSearchPanel.add(searchNameTextBox);

    searchButton = new Button(messages.searchButtonLabel());
    userSearchPanel.add(searchButton);
    searchButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            searchButton.setEnabled(false);
            findUsersByName(searchNameTextBox.getText());
        }
    });

    RootPanel searchResultsPanel = RootPanel.get(SEARCH_RESULTS_PANEL_ID);
    resultsFlexTable = new FlexTable();
    searchResultsPanel.add(resultsFlexTable);
    resultsFlexTable.setText(0, 0, messages.greeting());
}