Java Code Examples for com.google.gwt.user.client.ui.TextBox#setWidth()

The following examples show how to use com.google.gwt.user.client.ui.TextBox#setWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LabeledTextBox.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new TextBox with the given leading caption.
 *
 * @param caption  caption for leading label
 */
public LabeledTextBox(String caption) {
  HorizontalPanel panel = new HorizontalPanel();
  Label label = new Label(caption);
  panel.add(label);
  panel.setCellVerticalAlignment(label, HasVerticalAlignment.ALIGN_MIDDLE);
  textbox = new TextBox();
  textbox.setStylePrimaryName("ode-LabeledTextBox");
  textbox.setWidth("100%");
  panel.add(textbox);
  panel.setCellWidth(label, "40%");
  panel.setCellVerticalAlignment(textbox, HasVerticalAlignment.ALIGN_MIDDLE);

  initWidget(panel);

  setWidth("100%");
}
 
Example 2
Source File: LabeledTextBox.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Use this TextBox if you want to have text validation while a user is typing
 *
 * @param caption    caption for leading label
 * @param validator  The validator to use for a specific textBox
 */
public LabeledTextBox(String caption, Validator validator) {
  this.validator = validator;

  HorizontalPanel panel = new HorizontalPanel();
  Label label = new Label(caption);
  panel.add(label);
  panel.setCellVerticalAlignment(label, HasVerticalAlignment.ALIGN_MIDDLE);
  textbox = new TextBox();
  textbox.setStylePrimaryName("ode-LabeledTextBox");
  defaultTextBoxColor = textbox.getElement().getStyle().getBorderColor();
  textbox.setWidth("100%");
  panel.add(textbox);
  panel.setCellWidth(label, "40%");
  panel.setCellVerticalAlignment(textbox, HasVerticalAlignment.ALIGN_MIDDLE);

  HorizontalPanel errorPanel = new HorizontalPanel();
  errorLabel = new Label("");
  errorPanel.add(errorLabel);

  VerticalPanel vp = new VerticalPanel();
  vp.add(panel);
  vp.add(errorPanel);
  vp.setHeight("85px");

  initWidget(vp);

  setWidth("100%");
}
 
Example 3
Source File: ComponentImportWizard.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private Grid createUrlGrid() {
  TextBox urlTextBox = new TextBox();
  urlTextBox.setWidth("100%");
  Grid grid = new Grid(2, 1);
  grid.setWidget(0, 0, new Label("Url:"));
  grid.setWidget(1, 0, urlTextBox);
  return grid;
}
 
Example 4
Source File: UrlImportWizard.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private static Grid createUrlGrid() {
  TextBox urlTextBox = new TextBox();
  urlTextBox.setWidth("100%");
  Grid grid = new Grid(2, 1);
  grid.setWidget(0, 0, new Label("Url:"));
  grid.setWidget(1, 0, urlTextBox);
  return grid;
}
 
Example 5
Source File: HistoryViewer.java    From swellrt with Apache License 2.0 4 votes vote down vote up
public void buildUI() {

    //
    // Panel Left (document viewer and playback controls)
    //

    panelLeft = new VerticalPanel();
    panelLeft.add(docViewer.getWidget());
    panelLeft.setWidth("100%");
    setCSS(docViewer.getWidget(),
        "padding", "5px",
        "margin", "10px",
        "border", "1px solid darkgray",
        "min-height", "300px");


    panelPlayControl = new VerticalPanel();
    panelLeft.add(panelPlayControl);

    labelShowingRevision = new Label("Base revision #");
    panelPlayControl.add(labelShowingRevision);

    labelBaseRevision = new Label("?");
    panelPlayControl.add(labelBaseRevision);

    panelPlayControl.add(new Label("Diff with revision #"));
    boxTargetRevision = new TextBox();
    boxTargetRevision.setWidth("5em");
    boxTargetRevision.setValue("?");
    panelPlayControl.add(boxTargetRevision);


    btnShowDiff = new Button("Show diffs", new ClickHandler() {
      public void onClick(ClickEvent e) {

        try {
          int targetRevisionIndex = Integer.valueOf(boxTargetRevision.getValue());
          targetRevision = docHistory.getUnsafe(targetRevisionIndex);

          docViewer.removeContentAndUnrender();
          playbackDoc.renderDiff(baseRevision, targetRevision, doc -> {
          });
          docViewer.setContent(playbackDoc.getDocument());

        } catch (NumberFormatException ex) {

        }
      }
    });
    panelPlayControl.add(btnShowDiff);
    panelLeft.add(panelPlayControl);


    //
    // Right panel (history log)
    //

    panelRight = new VerticalPanel();

    DocHistory.Iterator history = docHistory.getIterator();

    traverseAllPrev(history, revision -> {
      panelRight.add(new Button(revision.toString(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
          docViewer.removeContentAndUnrender();
          playbackDoc.render(revision, doc -> {
          });
          docViewer.setContent(playbackDoc.getDocument());
          baseRevision = revision;
          labelBaseRevision.setText("" + baseRevision.getRevisionIndex());
        }

      }));

    });

    //
    //
    //

    HorizontalPanel mainPanel = new HorizontalPanel();
    mainPanel.setWidth("100%");

    mainPanel.add(panelLeft);
    mainPanel.setCellWidth(panelLeft, "75%");

    mainPanel.add(panelRight);
    mainPanel.setCellWidth(panelRight, "25%");

    initWidget(mainPanel);

  }