Example usage for com.google.gwt.user.client.ui HorizontalPanel setVerticalAlignment

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setVerticalAlignment

Introduction

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

Prototype

public void setVerticalAlignment(VerticalAlignmentConstant align) 

Source Link

Document

Sets the default vertical alignment to be used for widgets added to this panel.

Usage

From source file:com.mecatran.otp.gwt.client.view.ItinerarySummaryWidget.java

License:Open Source License

public ItinerarySummaryWidget(ItineraryBean itinerary, ClickHandler closeHandler, ClickHandler pinHandler) {
    VerticalPanel rootPanel = new VerticalPanel();

    // Addresses and close button top line
    HorizontalPanel departureAndButtonsPanel = new HorizontalPanel();
    departureAndButtonsPanel.addStyleName("itinerary-topbar-panel");
    rootPanel.add(departureAndButtonsPanel);

    // Departure and arrival time and addresses
    Grid departureAndArrivalPanel = new Grid(2, 2);
    departureAndArrivalPanel.addStyleName("itinerary-addresses-panel");
    departureAndButtonsPanel.add(departureAndArrivalPanel);
    departureAndButtonsPanel.setCellWidth(departureAndArrivalPanel, "100%");
    Label departureTimeLabel = new Label(FormatUtils.formatTime(itinerary.getDepartureTime()));
    departureTimeLabel.addStyleName("itinerary-departure-time");
    Label arrivalTimeLabel = new Label(FormatUtils.formatTime(itinerary.getArrivalTime()));
    arrivalTimeLabel.addStyleName("itinerary-arrival-time");
    String[] formattedAddresses = FormatUtils.formatAddresses(itinerary.getStartAddress(),
            itinerary.getEndAddress());//  w w  w. j a v  a2  s. c o m
    // TODO Use HTML::setStyleName() ?
    HTML departureAddressLabel = new HTML(
            "<div class='itinerary-address-inner'>" + formattedAddresses[0] + "</div>");
    departureAddressLabel.addStyleName("itinerary-address");
    HTML arrivalAddressLabel = new HTML(
            "<div class='itinerary-address-inner'>" + formattedAddresses[1] + "</div>");
    arrivalAddressLabel.addStyleName("itinerary-address");
    departureAndArrivalPanel.setWidget(0, 0, departureTimeLabel);
    departureAndArrivalPanel.setWidget(0, 1, departureAddressLabel);
    departureAndArrivalPanel.setWidget(1, 0, arrivalTimeLabel);
    departureAndArrivalPanel.setWidget(1, 1, arrivalAddressLabel);
    departureAndArrivalPanel.getColumnFormatter().setWidth(1, "100%");
    departureAndArrivalPanel.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
    departureAndArrivalPanel.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);

    // Buttons panel
    VerticalPanel buttonsPanel = new VerticalPanel();
    departureAndButtonsPanel.add(buttonsPanel);
    buttonsPanel.setCellHorizontalAlignment(buttonsPanel, HasHorizontalAlignment.ALIGN_RIGHT);

    // Close button
    PushButton closeButton = new PushButton(new Image(PlannerResources.INSTANCE.closeButtonPng()));
    closeButton.addStyleName("itinerary-close-button");
    closeButton.addClickHandler(closeHandler);
    buttonsPanel.add(closeButton);

    // Pin button
    pinButton = new ToggleButton(new Image(PlannerResources.INSTANCE.noFavoritePng()),
            new Image(PlannerResources.INSTANCE.favoritePng()));
    pinButton.addStyleName("itinerary-pin-button");
    pinButton.addClickHandler(pinHandler);
    buttonsPanel.add(pinButton);

    // Date, duration and travel mode summary
    HorizontalPanel timesAndSummaryPanel = new HorizontalPanel();
    timesAndSummaryPanel.setWidth("100%");
    timesAndSummaryPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    rootPanel.add(timesAndSummaryPanel);

    // Date and duration
    VerticalPanel dateAndDurationPanel = new VerticalPanel();
    dateAndDurationPanel.addStyleName("itinerary-date-duration-panel");
    timesAndSummaryPanel.add(dateAndDurationPanel);
    String departureDate = FormatUtils.formatDate(itinerary.getDepartureTime());
    String duration = FormatUtils.formatDuration(itinerary.getDurationSeconds());
    Label departureDateLabel = new Label(departureDate);
    departureDateLabel.addStyleName("itinerary-departure-date");
    dateAndDurationPanel.add(departureDateLabel);
    HTML durationLabel = new HTML(duration);
    durationLabel.addStyleName("itinerary-duration");
    dateAndDurationPanel.add(durationLabel);

    // Travel modes
    Panel modesAndLinksPanel = new VerticalPanel();
    timesAndSummaryPanel.add(modesAndLinksPanel);
    timesAndSummaryPanel.setCellWidth(modesAndLinksPanel, "100%");
    ItineraryModeLineWidget modeLine = new ItineraryModeLineWidget(itinerary);
    modeLine.addStyleName("itinerary-modeline-panel");
    modesAndLinksPanel.add(modeLine);

    // Links (show details, print)
    HorizontalPanel linksPanel = new HorizontalPanel();
    showHideDetailsLink = new Anchor(I18nUtils.tr("show.itinerary.details"));
    showHideDetailsLink.addStyleName("itinerary-details-show-hide");
    linksPanel.add(showHideDetailsLink);
    printLink = new Anchor(I18nUtils.tr("print.itinerary"));
    printLink.addStyleName("itinerary-details-print-link");
    linksPanel.add(printLink);
    modesAndLinksPanel.add(linksPanel);

    initWidget(rootPanel);
}

From source file:com.mecatran.otp.gwt.client.view.PlannerFormWidget.java

License:Open Source License

public PlannerFormWidget() {
    VerticalPanel rootPanel = new VerticalPanel();
    // Departure//from   www .  j a  v a  2  s .co m
    departureSuggestBox = new AddressProposalBox();
    departureSuggestBox.getAsWidget().addStyleName("departure-panel");
    departureSuggestBox.getAsWidget().addStyleName("departure-icon");
    departureSuggestBox.setAddressSuggestBoxListener(new AddressSuggestBoxListener() {
        @Override
        public void onLocationSelected(LocationBean location) {
            plannerWidgetListener.onStartLocationSelected(location);
        }

        @Override
        public void onLocationHover(LocationBean location) {
            plannerWidgetListener.onLocationHover(location);
        }

        @Override
        public void onFocus() {
            plannerWidget.focusDeparture();
        }
    });
    rootPanel.add(departureSuggestBox.getAsWidget());
    // Arrival
    arrivalSuggestBox = new AddressProposalBox();
    arrivalSuggestBox.getAsWidget().addStyleName("arrival-panel");
    arrivalSuggestBox.getAsWidget().addStyleName("arrival-icon");
    arrivalSuggestBox.setAddressSuggestBoxListener(new AddressSuggestBoxListener() {
        @Override
        public void onLocationSelected(LocationBean location) {
            plannerWidgetListener.onEndLocationSelected(location);
        }

        @Override
        public void onLocationHover(LocationBean location) {
            plannerWidgetListener.onLocationHover(location);
        }

        @Override
        public void onFocus() {
            plannerWidget.focusArrival();
        }
    });
    rootPanel.add(arrivalSuggestBox.getAsWidget());
    // Mode selector
    DropDownModeSelectorWidget modeSelectorWidget = new DropDownModeSelectorWidget();
    modeSelectorWidget.setModeSelectorListener(this);
    modeSelector = modeSelectorWidget;
    rootPanel.add(modeSelectorWidget);
    // Plan button
    HorizontalPanel planButtonPanel = new HorizontalPanel();
    planButtonPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
    planButton = new Button(I18nUtils.tr("plan.itinerary"));
    planButtonPanel.add(planButton);
    planButton.addStyleName("plan-button");
    planButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            plannerWidgetListener.onPlanningRequested();
        }
    });
    pleaseWaitPanel = new Label(I18nUtils.tr("please.wait"));
    planButtonPanel.add(pleaseWaitPanel);
    pleaseWaitPanel.setVisible(false);
    pleaseWaitPanel.addStyleName("please-wait-panel");
    pleaseWaitPanel.addStyleName("loading-icon");
    // Link anchor
    linkAnchor = new Anchor(I18nUtils.tr("link.to.this.page"));
    linkAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            linkTo();
        }
    });
    linkAnchor.addStyleName("link-anchor");
    planButtonPanel.add(linkAnchor);
    rootPanel.add(planButtonPanel);

    rootPanel.setWidth("100%");
    rootPanel.addStyleName("planner-form-panel");
    initWidget(rootPanel);
    setWidth("100%");
}

From source file:com.nitrous.gwt.earth.client.demo.ExecuteBatchDemo.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *//*from www. j  a  v  a 2  s  .  c  om*/
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    Button runBatchedButton = new Button("Batched calls");
    runBatchedButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            runBatched();
        }
    });

    Button runUnbatchedButton = new Button("Unbatched calls");
    runUnbatchedButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            runUnbatched();
        }
    });

    Button clearButton = new Button("Clear map");
    clearButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            clear();
        }
    });

    batchedResult = new HTML("&nbsp;");
    unbatchedResult = new HTML("&nbsp;");
    FlexTable resultTable = new FlexTable();
    resultTable.setBorderWidth(1);
    for (int row = 0; row < 2; row++) {
        for (int col = 0; col < 2; col++) {
            resultTable.getCellFormatter().setHeight(row, col, "20px");
            resultTable.getCellFormatter().setHorizontalAlignment(row, col,
                    HasHorizontalAlignment.ALIGN_CENTER);
        }
    }
    resultTable.setWidget(0, 0, runUnbatchedButton);
    resultTable.setWidget(1, 0, unbatchedResult);
    resultTable.setWidget(0, 1, runBatchedButton);
    resultTable.setWidget(1, 1, batchedResult);

    HorizontalPanel topPanel = new HorizontalPanel();
    topPanel.setWidth("100%");
    topPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    topPanel.add(resultTable);
    topPanel.add(clearButton);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(topPanel, 80D);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.FetchKmlInteractive.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *//*from  w  w  w.j  av  a  2 s  .c om*/
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    kmlUrlBox = new TextBox();
    kmlUrlBox.getElement().setAttribute("size", "70");
    kmlUrlBox.setValue("http://earth-api-samples.googlecode.com/svn/trunk/examples/static/red.kml");

    Button fetchKmlButton = new Button("Fetch KML!");
    fetchKmlButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            fetchKmlFromInput();
        }
    });

    HorizontalPanel urlPanel = new HorizontalPanel();
    urlPanel.setSpacing(5);
    urlPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    urlPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    urlPanel.add(new Label("Fetch KML at this URL:"));
    urlPanel.add(kmlUrlBox);
    urlPanel.add(fetchKmlButton);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(urlPanel, 40);
    layout.add(earth);
    // add the widget to the DOM
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.FetchKmlInteractiveCheckboxes.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *//*from w ww. java2s.c  o m*/
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    currentKmlObjects = new HashMap<String, KmlObject>();

    checkBoxes = new HashMap<String, CheckBox>();
    red = new CheckBox("Red Placemarks");
    red.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            toggleKml("red");
        }
    });
    checkBoxes.put("red", red);

    yellow = new CheckBox("Yellow Placemarks");
    yellow.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            toggleKml("yellow");
        }
    });
    checkBoxes.put("yellow", yellow);

    green = new CheckBox("Green Placemarks");
    green.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            toggleKml("green");
        }
    });
    checkBoxes.put("green", green);

    HorizontalPanel header = new HorizontalPanel();
    header.setSpacing(5);
    header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    header.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    header.add(new HTML("<H1>Toggle KML Files:</H1>"));

    VerticalPanel checkBoxes = new VerticalPanel();
    checkBoxes.setSpacing(5);
    checkBoxes.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    checkBoxes.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    checkBoxes.add(red);
    checkBoxes.add(yellow);
    checkBoxes.add(green);
    header.add(checkBoxes);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(header, 100);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.ParseKmlInteractive.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *//*from   w  w  w  .  j  a  va2 s  .  com*/
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    kmlBox = new TextArea();
    kmlBox.getElement().setAttribute("rows", "10");
    kmlBox.getElement().setAttribute("cols", "70");
    kmlBox.getElement().setAttribute("wrap", "off");
    kmlBox.getElement().setAttribute("style", "font-family: monospace; font-size: small");
    kmlBox.setValue(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
                    + "  <Placemark>\n" + "    <name>Test Placemark</name>\n" + "    <Point>\n"
                    + "      <coordinates>\n" + "        -122,37,0\n" + "      </coordinates>\n"
                    + "    </Point>\n" + "  </Placemark>\n" + "</kml>");

    Button parseKmlButton = new Button("Parse and Add this KML!");
    parseKmlButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            parseKmlFromTextArea();
        }
    });

    HorizontalPanel textPanel = new HorizontalPanel();
    textPanel.setSpacing(5);
    textPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    textPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    textPanel.add(kmlBox);
    textPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    textPanel.add(parseKmlButton);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(textPanel, 220);
    layout.add(earth);
    // add the widget to the DOM
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.novartis.pcs.ontology.webapp.client.view.ApproveRejectComposite.java

License:Apache License

protected void addWidgets() {
    VerticalPanel vertPanel = new VerticalPanel();
    HorizontalPanel filterPanel = new HorizontalPanel();
    Label filterLabel = new Label("Keyword Filter:");

    Button closeButton = new Button("Close");
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true) {
        @Override/* w  w w  .j  a  v  a 2 s  . com*/
        public void setPageStart(int index) {
            HasRows display = getDisplay();
            if (display != null) {
                Range range = display.getVisibleRange();
                int pageSize = range.getLength();
                if (isRangeLimited() && display.isRowCountExact()) {
                    index = Math.min(index, display.getRowCount() - 1);
                }
                index = Math.max(0, index);
                if (index != range.getStart()) {
                    display.setVisibleRange(index, pageSize);
                }
            }
        }
    };

    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Widget parent = ApproveRejectComposite.this.getParent();
            while (parent != null) {
                if (parent instanceof PopupPanel) {
                    PopupPanel popup = (PopupPanel) parent;
                    popup.hide();
                    break;
                }
                parent = parent.getParent();
            }
        }
    });

    filterLabel.addStyleName("dialog-label");

    filterPanel.addStyleName("dialog-hpanel");
    filterPanel.addStyleName("spaced-vert");
    filterPanel.add(filterLabel);
    filterPanel.add(filterTextBox);
    filterPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    pager.setDisplay(table);
    pager.addStyleName("centered-hortz");
    /*
    if(curator != null && curator.isAuthorised(entity)) {
       Label tip = new Label("Use Shift key to select/unselect consecutive rows");
       tip.addStyleName("dialog-message");
       tip.addStyleName("info-icon-left");
       vertPanel.add(tip);
    } else {
       Label label = new Label("Insufficient privileges to approve/reject items");
       label.addStyleName("dialog-message");
       label.addStyleName("info-icon-left");
       vertPanel.add(label);
    }
    */

    if (curator != null) {
        vertPanel.add(errorLabel);
    }
    vertPanel.add(filterPanel);
    vertPanel.add(table);
    vertPanel.add(pager);

    if (curator != null && curator.isAuthorised(entity)) {
        Label comments = new Label("Comments:");
        HorizontalPanel buttonsHPanel = new HorizontalPanel();

        buttonsHPanel.add(approveButton);
        buttonsHPanel.add(rejectButton);
        buttonsHPanel.add(closeButton);

        comments.addStyleName("dialog-label");
        buttonsHPanel.addStyleName("dialog-buttons");
        buttonsHPanel.addStyleName("centered-hortz");

        vertPanel.add(comments);
        vertPanel.add(commentsField);
        commentsField.getElement().getParentElement().addClassName("text-area-right-padded");

        vertPanel.add(buttonsHPanel);
    } else {
        vertPanel.add(closeButton);
        vertPanel.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);
    }
    initWidget(vertPanel);
}

From source file:com.novartis.pcs.ontology.webapp.client.view.HistoryPopup.java

License:Apache License

private void addDialogWidgets() {
    VerticalPanel vertPanel = new VerticalPanel();
    HorizontalPanel filterPanel = new HorizontalPanel();
    Label filterLabel = new Label("Keyword Filter:");
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true) {
        @Override/*from  w  ww.  jav a2 s .c  o  m*/
        public void setPageStart(int index) {
            HasRows display = getDisplay();
            if (display != null) {
                Range range = display.getVisibleRange();
                int pageSize = range.getLength();
                if (isRangeLimited() && display.isRowCountExact()) {
                    index = Math.min(index, display.getRowCount() - 1);
                }
                index = Math.max(0, index);
                if (index != range.getStart()) {
                    display.setVisibleRange(index, pageSize);
                }
            }
        }
    };
    Button closeButton = new Button("Close");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    filterLabel.addStyleName("dialog-label");

    filterPanel.addStyleName("dialog-hpanel");
    filterPanel.add(filterLabel);
    filterPanel.add(filterTextBox);
    filterPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    pager.addStyleName("centered-hortz");
    pager.setDisplay(table);

    vertPanel.addStyleName("dialog-vpanel");
    vertPanel.add(filterPanel);
    vertPanel.add(table);
    vertPanel.add(pager);
    vertPanel.add(closeButton);
    vertPanel.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);
    dialogBox.setWidget(vertPanel);
}

From source file:com.pietschy.gwt.pectin.demo.client.misc.VerySimpleForm.java

License:Apache License

protected Widget hp(Widget first, Widget... others) {
    if (others.length == 0) {
        return first;
    }/*  ww  w .  ja va 2 s .co  m*/

    HorizontalPanel p = new HorizontalPanel();
    p.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    p.add(first);
    for (Widget other : others) {
        // mmmm.. hacky.
        p.add(new HTML("&nbsp;&nbsp;"));
        p.add(other);
    }
    return p;
}

From source file:com.pietschy.gwt.pectin.demo.client.misc.VerySimpleForm.java

License:Apache License

protected Widget hpWithNoGap(Widget first, Widget... others) {
    if (others.length == 0) {
        return first;
    }/*  ww w . j a va2  s  .  co  m*/

    HorizontalPanel p = new HorizontalPanel();
    p.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    p.add(first);
    for (Widget other : others) {
        p.add(other);
    }
    return p;
}