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

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

Introduction

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

Prototype

public void setText(String text) 

Source Link

Document

Sets the label's content to the given text.

Usage

From source file:net.officefloor.tutorial.gwtservice.client.GwtAppEntryPoint.java

License:Open Source License

@Override
public void onModuleLoad() {

    // Obtain panel to load game
    Panel panel = RootPanel.get("HighLowGame");

    // Add Game widgets
    VerticalPanel gamePanel = new VerticalPanel();
    panel.add(gamePanel);//ww  w . ja  v a  2 s  .c om
    gamePanel.add(new Label("Enter a number (between 1 and 100):"));
    HorizontalPanel tryPanel = new HorizontalPanel();
    gamePanel.add(tryPanel);
    final TextBox text = new TextBox();
    tryPanel.add(text);
    final Button button = new Button("Try");
    tryPanel.add(button);
    final Label message = new Label();
    gamePanel.add(message);

    // Handle try button click
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            // Obtain the value to try
            Integer value;
            try {
                value = Integer.valueOf(text.getText());
            } catch (NumberFormatException ex) {
                Window.alert("Please enter a valid number");
                return;
            }

            // Attempt try (calls on Server)
            service.attempt(value, new AsyncCallback<Result>() {
                @Override
                public void onSuccess(Result result) {
                    switch (result.getAnswer()) {
                    case HIGHER:
                        message.setText("Higher");
                        text.setText("");
                        break;
                    case LOWER:
                        message.setText("Lower");
                        text.setText("");
                        break;
                    case CORRECT:
                        message.setText("Correct. Well done!");
                        text.setEnabled(false);
                        button.setEnabled(false);
                        break;
                    case NO_FURTHER_ATTEMPTS:
                        message.setText("No further attempts. Number was " + result.getNumber());
                        text.setEnabled(false);
                        button.setEnabled(false);
                        break;
                    }
                }

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Technical failure: " + caught.getMessage() + " ["
                            + caught.getClass().getName() + "]");
                }
            });
        }
    });
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.text.CwBasicText.java

License:Apache License

/**
 * Update the text in one of the selection labels.
 * //www  . jav a2s  .c  om
 * @param textBox the text box
 * @param label the label to update
 */
private void updateSelectionLabel(TextBoxBase textBox, Label label) {
    label.setText(constants.cwBasicTextSelected() + ": " + textBox.getCursorPos() + ", "
            + textBox.getSelectionLength());
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.widgets.CwDatePicker.java

License:Apache License

/**
 * Initialize this example./*www  .j a  v  a  2  s .co  m*/
 */
@Override
public Widget onInitialize() {
    // Create a basic date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
        public void onValueChange(ValueChangeEvent<Date> event) {
            Date date = event.getValue();
            String dateString = DateTimeFormat.getMediumDateFormat().format(date);
            text.setText(dateString);
        }
    });

    // Set the default value
    datePicker.setValue(new Date(), true);

    // Create a DateBox
    DateBox dateBox = new DateBox();

    // Combine the widgets into a panel and return them
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(new HTML(constants.cwDatePickerLabel()));
    vPanel.add(text);
    vPanel.add(datePicker);
    vPanel.add(new HTML(constants.cwDatePickerBoxLabel()));
    vPanel.add(dateBox);
    return vPanel;
}

From source file:net.sf.gudoku.client.widget.SudokuBoard.java

License:Open Source License

protected void setRowChecksum(Cell cell) {
    int rowChecksum = gudoku.getSudoku().getRowChecksum(Cell.mapClientRow2ServerRow(cell.getRow()));
    Label l = null;
    RootPanel rp = RootPanel.get("Row_" + String.valueOf(cell.getRow()));
    if (rp != null && rp.getWidgetCount() > 0) {
        l = (Label) rp.getWidget(0);
    } else {/*from   ww w  .ja  va 2s  .  c  o m*/
        l = new Label();
        l.addStyleName("rowChecksum");
        rp.clear();
        rp.add(l);
    }
    l.setText(String.valueOf(rowChecksum));
    l.setTitle(String.valueOf(rowChecksum) + " von " + gudoku.getSudokuSize().getUnitChecksum());
    setChecksumStyle(l, rowChecksum);
}

From source file:net.sf.gudoku.client.widget.SudokuBoard.java

License:Open Source License

protected void setColumnChecksum(Cell cell) {
    int columnChecksum = gudoku.getSudoku()
            .getColumnChecksum(Cell.mapClientColumn2ServerColumn(cell.getColumn()));
    Label l = null;
    RootPanel rp = RootPanel.get("Column_" + String.valueOf(cell.getColumn()));
    if (rp != null && rp.getWidgetCount() > 0) {
        l = (Label) rp.getWidget(0);
    } else {/* w  w  w. ja va 2s . co m*/
        l = new Label();
        l.addStyleName("columnChecksum");
        rp.clear();
        rp.add(l);
    }
    l.setText(String.valueOf(columnChecksum));
    l.setTitle(String.valueOf(columnChecksum) + " vom " + gudoku.getSudokuSize().getUnitChecksum());
    setChecksumStyle(l, columnChecksum);
}

From source file:next.celebs.page.SearchPage.java

License:Apache License

public SearchPage(Context ctx_) {
    this.ctx = ctx_;
    setStyleName("ySearchPage yPopupPage");
    setWidth(WIDTH + "px");

    setPopupPosition(336, 88);/*w w  w  . j a va  2s .c om*/
    show();

    FlowPanel content = new FlowPanel();
    setWidget(content);

    FlexTable ft = new FlexTable();
    ft.setWidth(WIDTH + "px");

    final TextBox box = new TextBox();
    ImageButton btnDone = new ImageButton(RES.btnDone());
    final Label celebField = new Label();
    celebField.setStyleName("ySearchName");

    btnDone.addMouseDownHandler(new MouseDownHandler() {
        @Override
        public void onMouseDown(MouseDownEvent event) {
            String celebName = MiscUtils.noNull(celebField.getText());
            if (!MiscUtils.isEmpty(box.getText()) || celebName.length() > 1) {
                doHide();
                ctx.getEventBus().fireEvent(new SearchEvent(box.getText() + " " + celebName));
            }
        }
    });

    FlowPanel scrNested = new FlowPanel();
    ScrollPanel scrollPanel = new ScrollPanel(scrNested);
    init(scrollPanel, scrNested, celebField);

    ImageButton btnClear = new ImageButton(RES.btnClear());
    btnClear.addMouseDownHandler(new MouseDownHandler() {
        @Override
        public void onMouseDown(MouseDownEvent event) {
            box.setText("");
            celebField.setText("");
        }
    });

    celebField.setWidth("240px");

    ft.setWidget(0, 0, box);
    ft.setWidget(0, 1, celebField);
    ft.setWidget(0, 2, btnClear);
    ft.setWidget(1, 0, btnDone);
    ft.setWidget(1, 1, scrollPanel);

    ft.getRowFormatter().setStyleName(0, "ySearchRow");

    FlexCellFormatter fcf = ft.getFlexCellFormatter();
    fcf.setColSpan(1, 1, 2);

    fcf.setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_BOTTOM);

    content.add(ft);
}

From source file:next.celebs.page.SearchPage.java

License:Apache License

void init(ScrollPanel scrollPanel, FlowPanel nested, final Label celebField) {

    scrollPanel.setSize("100%", "400px");
    MiscUtils.populateNamesScrollPanel(new CallBack() {
        @Override// w ww.j ava  2 s.  c  o  m
        public void onClick(String name) {
            celebField.setText(name);
        }
    }, nested, ctx);
}

From source file:next.interfaces.controller.widgets.SliderController.java

License:Apache License

private void addHandlers(final Label label, XSlider... sliders) {
    for (final XSlider s : sliders) {
        s.addValueChangeHandler(new ValueChangeHandler<Integer>() {
            public void onValueChange(ValueChangeEvent<Integer> e) {
                label.setText("Slided at: " + e.getValue() + "%");
            }//from   w w w.j  av a 2  s .co  m
        });
    }
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.LocalStoragePresenter.java

License:Open Source License

protected void addKeyboardDebug() {
    final Label clickLabel = new Label();
    final Label mouseLabel = new Label();
    final Label wheelLabel = new Label();
    final Label keyDownLabel = new Label();

    ((ComplexView) simpleView).addWidget(clickLabel);
    ((ComplexView) simpleView).addWidget(mouseLabel);
    ((ComplexView) simpleView).addWidget(wheelLabel);
    ((ComplexView) simpleView).addWidget(keyDownLabel);
    RootPanel root = RootPanel.get();/*w  w  w  .  ja  v  a 2  s .  co m*/
    root.addDomHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            clickLabel.setText(event.toDebugString());
        }
    }, KeyUpEvent.getType());
    root.addDomHandler(new MouseWheelHandler() {
        @Override
        public void onMouseWheel(MouseWheelEvent event) {
            wheelLabel.setText(event.getX() + " : " + event.getY() + " DeltaY: " + event.getDeltaY());
        }
    }, MouseWheelEvent.getType());
    root.addDomHandler(new MouseMoveHandler() {
        @Override
        public void onMouseMove(MouseMoveEvent event) {
            mouseLabel.setText(event.getX() + " : " + event.getY());
        }
    }, MouseMoveEvent.getType());
    root.addDomHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            //                final int nativeKeyCode = event.getNativeKeyCode();
            keyDownLabel.setText("NativeKeyCode: " + event.getNativeKeyCode() + " AltKey:"
                    + event.isAltKeyDown() + " ControlKey:" + event.isControlKeyDown() + " DownArrow:"
                    + event.isDownArrow() + " LeftArrow:" + event.isLeftArrow() + " MetaKey:"
                    + event.isMetaKeyDown() + " RightArrow:" + event.isRightArrow() + " ShiftKey:"
                    + event.isShiftKeyDown() + " UpArrow:" + event.isUpArrow());
        }
    }, KeyDownEvent.getType());
}

From source file:nl.mpi.tg.eg.experiment.client.view.AnnotationTimelinePanel.java

License:Open Source License

public void updateAnnotationText(final AnnotationData annotationData) {
    final Label label = annotationLebels.get(annotationData);
    label.setText(annotationData.getAnnotationHtml());
}