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

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

Introduction

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

Prototype

public void setVisibleLength(int length) 

Source Link

Document

Sets the number of visible characters in the text box.

Usage

From source file:piramide.interaction.reasoner.web.client.ui.fuzzy.AddEditLinguisticTermPanel.java

License:Apache License

@UiHandler("addLinguisticTermButton")
void onAddLinguisticTermButtonClicked(ClickEvent event) {
    final DialogBox addDialogBox = new DialogBox();
    addDialogBox.setGlassEnabled(true);// w  w  w . ja  va2 s .  c  o m

    addDialogBox.setText(messages.add());

    final VerticalPanel vpanel = new VerticalPanel();
    vpanel.add(new Label(messages.addLinguisticTerm()));
    final TextBox textbox = new TextBox();
    textbox.setVisibleLength(10);
    vpanel.add(textbox);

    final HorizontalPanel hpanel = new HorizontalPanel();
    final Button cancelButton = new Button(messages.cancel());
    final Button addButton = new Button(messages.add());

    hpanel.add(addButton);
    hpanel.add(cancelButton);
    vpanel.add(hpanel);

    addDialogBox.setWidget(vpanel);

    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            addDialogBox.hide();
        }
    });

    final ClickHandler handler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            addDialogBox.hide();
            AddEditLinguisticTermPanel.this.linguisticTermsListBox.addItem(textbox.getText());
            AddEditLinguisticTermPanel.this.addLinguisticTermButton.setFocus(true);
        }
    };

    final KeyPressHandler keyboardHandler = new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER)
                handler.onClick(null);
        }
    };

    textbox.addKeyPressHandler(keyboardHandler);
    addButton.addClickHandler(handler);

    addDialogBox.center();
    addDialogBox.show();

    textbox.setFocus(true);
}