Example usage for com.google.gwt.user.client.ui DialogBox setText

List of usage examples for com.google.gwt.user.client.ui DialogBox setText

Introduction

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

Prototype

public void setText(String text) 

Source Link

Document

Sets the text inside the caption by calling its #setText(String) method.

Usage

From source file:com.google.code.gwt.iui.sample.helloiui.client.HelloiUI.java

License:Apache License

/**
 * This is the entry point method.//from w  w w.ja v a2s.  co  m
 */
public void onModuleLoad() {
    Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
    Button button = new Button("Click me");

    VerticalPanel vPanel = new VerticalPanel();
    // We can add style names.
    vPanel.addStyleName("widePanel");
    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.add(img);
    vPanel.add(button);

    // Add image and button to the RootPanel
    RootPanel.get().add(vPanel);

    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Welcome to GWT iUI Demo!");
    dialogBox.setAnimationEnabled(true);
    Button closeButton = new Button("close");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.add(closeButton);

    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    // Set the contents of the Widget
    dialogBox.setWidget(dialogVPanel);

    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.center();
            dialogBox.show();
        }
    });
}

From source file:com.google.code.gwt.template.sample.hellotemplate.client.HelloTemplate.java

License:Apache License

/**
 * This is the entry point method./*  www.  j  ava2  s. c  om*/
 */
public void onModuleLoad() {
    Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
    Button button = new Button("Click me");

    VerticalPanel vPanel = new VerticalPanel();
    // We can add style names.
    vPanel.addStyleName("widePanel");
    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.add(img);
    vPanel.add(button);

    // Add image and button to the RootPanel
    RootPanel.get().add(vPanel);

    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Welcome to GWT Template Demo!");
    dialogBox.setAnimationEnabled(true);
    Button closeButton = new Button("close");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.add(closeButton);

    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    // Set the contents of the Widget
    dialogBox.setWidget(dialogVPanel);

    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.center();
            dialogBox.show();
        }
    });
}

From source file:com.google.developers.gdgfirenze.gwt.client.GwtDemoApp.java

License:Apache License

/**
 * This is the entry point method.//from ww  w.j  a va 2 s  .c o m
 */
public void onModuleLoad() {
    final Button sendButton = new Button("Send");
    final TextBox nameField = new TextBox();
    nameField.setText("GWT User");
    final Label errorLabel = new Label();

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);

    // Focus the cursor on the name field when the app loads
    nameField.setFocus(true);
    nameField.selectAll();

    // Create the popup dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    final Button closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    final Label textToServerLabel = new Label();
    final HTML serverResponseLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
    dialogVPanel.add(textToServerLabel);
    dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
    dialogVPanel.add(serverResponseLabel);
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    // Add a handler to close the DialogBox
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            sendButton.setEnabled(true);
            sendButton.setFocus(true);
        }
    });

    /**
     * The Class MyHandler.
     * 
     * Create a handler for the sendButton and nameField
     */
    class MyHandler implements ClickHandler, KeyUpHandler {
        /**
         * Fired when the user clicks on the sendButton.
         */
        public void onClick(ClickEvent event) {
            sendNameToServer();
        }

        /**
         * Fired when the user types in the nameField.
         */
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                sendNameToServer();
            }
        }

        /**
         * Send the name from the nameField to the server and wait for a response.
         */
        private void sendNameToServer() {
            // First, we validate the input.
            errorLabel.setText("");
            String textToServer = nameField.getText();
            if (!FieldVerifier.isValidName(textToServer)) {
                errorLabel.setText("Please enter at least four characters");
                return;
            }

            // Then, we send the input to the server.
            sendButton.setEnabled(false);
            textToServerLabel.setText(textToServer);
            serverResponseLabel.setText("");
            greetingService.greetServer(textToServer, new AsyncCallback<String>() {
                public void onFailure(Throwable caught) {
                    // Show the RPC error message to the user
                    dialogBox.setText("Remote Procedure Call - Failure");
                    serverResponseLabel.addStyleName("serverResponseLabelError");
                    serverResponseLabel.setHTML(SERVER_ERROR);
                    dialogBox.center();
                    closeButton.setFocus(true);
                }

                public void onSuccess(String result) {
                    dialogBox.setText("Remote Procedure Call");
                    serverResponseLabel.removeStyleName("serverResponseLabelError");
                    serverResponseLabel.setHTML(result);
                    dialogBox.center();
                    closeButton.setFocus(true);
                }
            });
        }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);
}

From source file:com.google.gwt.gadgets.sample.hellogadgets.client.HelloGadgets.java

License:Apache License

@Override
protected void init(final HelloPreferences prefs) {
    Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
    Button button = new Button("Click me");

    VerticalPanel vPanel = new VerticalPanel();
    vPanel.setWidth("100%");
    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.add(img);//from   w  w w  . java 2  s . c o m
    vPanel.add(button);

    RootPanel.get().add(vPanel);

    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();

    // The content of the dialog comes from a User specified Preference
    dialogBox.setText(prefs.promptSomethingElse().getValue());
    dialogBox.setAnimationEnabled(true);
    Button closeButton = new Button("Close");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.add(closeButton);

    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    // Set the contents of the Widget
    dialogBox.setWidget(dialogVPanel);

    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.center();
            dialogBox.show();
        }
    });
}

From source file:com.google.gwt.gwtai.demo.client.CounterAppletTab.java

License:Apache License

private DialogBox createDialogBox(Object currentValue) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Current...");

    VerticalPanel panelContent = new VerticalPanel();
    panelContent.setWidth("100%");
    panelContent.setSpacing(4);//from   w  w  w  .  j  a v  a 2s  .  com
    dialogBox.setWidget(panelContent);

    HTML labelCurrentValue = new HTML("The current count is : " + currentValue);
    panelContent.add(labelCurrentValue);
    panelContent.setCellHorizontalAlignment(labelCurrentValue, VerticalPanel.ALIGN_CENTER);

    Button buttonCloseDlg = new Button("Close");
    buttonCloseDlg.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    panelContent.add(buttonCloseDlg);
    panelContent.setCellHorizontalAlignment(buttonCloseDlg, VerticalPanel.ALIGN_RIGHT);

    return dialogBox;
}

From source file:com.google.gwt.sample.hellomaps.client.HelloMaps.java

License:Apache License

private void createMap() {
    // Set the map up in a Dialog box, just for fun.
    final DialogBox dialog = new DialogBox(false, false);
    final Map theMap = new Map();
    final Button findButton = new Button("Address:");
    final TextBox tb = new TextBox();
    tb.addKeyboardListener(new KeyboardListenerAdapter() {
        @Override//from w w w  .  j  a  va 2 s  .com
        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KEY_ENTER) {
                theMap.setLocation(((TextBox) sender).getText());
            } else if (keyCode == KEY_ESCAPE) {
                dialog.removeFromParent();
            }
        }
    });
    findButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            theMap.setLocation(tb.getText());
        }
    });
    tb.setWidth("100%");

    final HorizontalPanel hp = new HorizontalPanel();
    hp.add(findButton);
    hp.setCellWidth(findButton, "15%");
    hp.add(tb);
    hp.setCellWidth(tb, "85%");

    final VerticalPanel vp = new VerticalPanel();
    vp.add(hp);
    vp.add(theMap);

    dialog.setText("Drag me!");
    dialog.setWidget(vp);
    dialog.center();
}

From source file:com.google.gwt.sample.mobilewebapp.client.desktop.MobileWebAppShellDesktop.java

License:Apache License

/**
 * Show a tutorial video.//from   w w  w . jav  a2 s . com
 */
private void showTutorial() {
    // Reuse the tutorial dialog if it is already created.
    if (tutoralPopup != null) {
        // Reset the video.
        // TODO(jlabanca): Is cache-control=private making the video non-seekable?
        if (tutorialVideo != null) {
            tutorialVideo.setSrc(tutorialVideo.getCurrentSrc());
        }

        tutoralPopup.center();
        return;
    }

    /*
     * Forward the use to YouTube if video is not supported or if none of the
     * source formats are supported.
     */
    tutorialVideo = Video.createIfSupported();
    if (tutorialVideo == null) {
        Label label = new Label("Click the link below to view the tutoral:");
        Anchor anchor = new Anchor(EXTERNAL_TUTORIAL_URL, EXTERNAL_TUTORIAL_URL);
        anchor.setTarget("_blank");
        FlowPanel panel = new FlowPanel();
        panel.add(label);
        panel.add(anchor);

        tutoralPopup = new PopupPanel(true, false);
        tutoralPopup.setWidget(panel);
        tutoralPopup.setGlassEnabled(true);

        // Hide the popup when the user clicks the link.
        anchor.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                tutoralPopup.hide();
            }
        });

        tutoralPopup.center();
        return;
    }

    // Add the video sources.
    tutorialVideo.addSource("video/tutorial.ogv", VideoElement.TYPE_OGG);
    tutorialVideo.addSource("video/tutorial.mp4", VideoElement.TYPE_MP4);

    // Setup the video player.
    tutorialVideo.setControls(true);
    tutorialVideo.setAutoplay(true);

    // Put the video in a dialog.
    final DialogBox popup = new DialogBox(false, false);
    popup.setText("Tutorial");
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(tutorialVideo);
    vPanel.add(new Button("Close", new ClickHandler() {
        public void onClick(ClickEvent event) {
            tutorialVideo.pause();
            popup.hide();
        }
    }));
    popup.setWidget(vPanel);
    tutoralPopup = popup;
    popup.center();
}

From source file:com.google.gwt.sample.showcase.client.content.popups.CwDialogBox.java

License:Apache License

/**
 * Create the dialog box for this example.
 *
 * @return the new dialog box/*from  w w  w  .  j a v a 2 s . co m*/
 */
@ShowcaseSource
private DialogBox createDialogBox() {
    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox();
    dialogBox.ensureDebugId("cwDialogBox");
    dialogBox.setText(constants.cwDialogBoxCaption());

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);
    dialogBox.setWidget(dialogContents);

    // Add some text to the top of the dialog
    HTML details = new HTML(constants.cwDialogBoxDetails());
    dialogContents.add(details);
    dialogContents.setCellHorizontalAlignment(details, HasHorizontalAlignment.ALIGN_CENTER);

    // Add an image to the dialog
    Image image = new Image(Showcase.images.jimmy());
    dialogContents.add(image);
    dialogContents.setCellHorizontalAlignment(image, HasHorizontalAlignment.ALIGN_CENTER);

    // Add a close button at the bottom of the dialog
    Button closeButton = new Button(constants.cwDialogBoxClose(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogContents.add(closeButton);
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_LEFT);

    } else {
        dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Return the dialog box
    return dialogBox;
}

From source file:com.google.gwt.sample.starter.client.Starter.java

/**
 * This is the entry point method.//from  w ww  . j  a  v  a 2s .com
 */
public void onModuleLoad() {
    final Button sendButton = new Button("Send");
    final TextBox nameField = new TextBox();
    nameField.setText("GWT User");
    final Label errorLabel = new Label();

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);

    // Focus the cursor on the name field when the app loads
    nameField.setFocus(true);
    nameField.selectAll();

    // Create the popup dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    final Button closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    final Label textToServerLabel = new Label();
    final HTML serverResponseLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
    dialogVPanel.add(textToServerLabel);
    dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
    dialogVPanel.add(serverResponseLabel);
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    // Add a handler to close the DialogBox
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            sendButton.setEnabled(true);
            sendButton.setFocus(true);
        }
    });

    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler, KeyUpHandler {
        /**
         * Fired when the user clicks on the sendButton.
         */
        public void onClick(ClickEvent event) {
            sendNameToServer();
        }

        /**
         * Fired when the user types in the nameField.
         */
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                sendNameToServer();
            }
        }

        /**
         * Send the name from the nameField to the server and wait for a response.
         */
        private void sendNameToServer() {
            // First, we validate the input.
            errorLabel.setText("");
            String textToServer = nameField.getText();
            if (!FieldVerifier.isValidName(textToServer)) {
                errorLabel.setText("Please enter at least four characters");
                return;
            }

            // Then, we send the input to the server.
            sendButton.setEnabled(false);
            textToServerLabel.setText(textToServer);
            serverResponseLabel.setText("");
            greetingService.greetServer(textToServer, new AsyncCallback<String>() {
                public void onFailure(Throwable caught) {
                    // Show the RPC error message to the user
                    dialogBox.setText("Remote Procedure Call - Failure");
                    serverResponseLabel.addStyleName("serverResponseLabelError");
                    serverResponseLabel.setHTML(SERVER_ERROR);
                    dialogBox.center();
                    closeButton.setFocus(true);
                }

                public void onSuccess(String result) {
                    dialogBox.setText("Remote Procedure Call");
                    serverResponseLabel.removeStyleName("serverResponseLabelError");
                    serverResponseLabel.setHTML(result);
                    dialogBox.center();
                    closeButton.setFocus(true);
                }
            });
        }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);
}

From source file:com.google.testing.testify.risk.frontend.client.view.widgets.StandardDialogBox.java

License:Apache License

/**
 * Displays the Dialog./*from ww w.  ja va  2s  .c  om*/
 */
public static void showAsDialog(StandardDialogBox dialogWidget) {
    DialogBox dialogBox = new DialogBox();
    dialogWidget.dialogBox = dialogBox;

    dialogBox.addStyleName("tty-StandardDialogBox");
    dialogBox.setText(dialogWidget.getTitle());
    dialogBox.add(dialogWidget);
    dialogBox.center();
    dialogBox.show();
}