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

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

Introduction

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

Prototype

public void setSpacing(int spacing) 

Source Link

Document

Sets the amount of spacing between this panel's cells.

Usage

From source file:net.autosauler.ballance.client.gui.QuestionDialog.java

License:Apache License

/**
 * Instantiates a new question dialog.//from  w w  w .  j  a  v a 2 s .  c o  m
 * 
 * @param question
 *            the question
 * @param receiver
 *            the receiver
 * @param tag
 *            the tag
 * @param tag2
 *            the tag2
 */
public QuestionDialog(String question, IDialogYesReceiver receiver, String tag, Object tag2) {
    yesreceiver = receiver;
    mytag = tag;
    mytag2 = tag2;

    setHeading(M.dialog.msgTitle());
    setAnimCollapse(true);
    setAutoHeight(true);
    setAutoWidth(true);
    setBlinkModal(true);
    setClosable(false);
    setDraggable(true);
    setModal(true);
    setShadow(true);

    Button yes = new Button(M.dialog.btnYes());

    yes.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            yesreceiver.onDialogYesButtonClick(mytag, mytag2);
            QuestionDialog.this.hide();

        }

    });

    Button no = new Button(M.dialog.btnNo());
    no.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            QuestionDialog.this.hide();

        }

    });

    VerticalPanel vpanel = new VerticalPanel();

    HorizontalPanel qpanel = new HorizontalPanel();
    qpanel.setSpacing(15);
    qpanel.add(new Image(Images.menu.icoQuestion()));
    qpanel.add(new Label(question));
    vpanel.add(qpanel);

    this.add(vpanel);
    getButtonBar().removeAll();
    addButton(yes);
    addButton(no);

    no.focus();

}

From source file:net.officefloor.demo.chat.client.ChatWidget.java

License:Open Source License

/**
 * Ensures that have user name./*  ww  w  .  j a  va2s.c  o  m*/
 */
private void ensureHaveUserName() {

    // Determine if user name already specified
    if ((this.userName != null) && (this.userName.trim().length() > 0)) {
        return; // user name specified
    }

    // No user name so obtain the user name
    final DialogBox userDialog = new DialogBox(false, true);
    HorizontalPanel userPanel = new HorizontalPanel();
    userPanel.setSpacing(10);
    userPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    userDialog.add(userPanel);
    userPanel.add(new Label("Enter name for chat"));
    final TextBox nameText = new TextBox();
    nameText.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (KeyCodes.KEY_ENTER == event.getNativeKeyCode()) {
                ChatWidget.this.enterChatName(nameText, userDialog);
            }
        }
    });
    userPanel.add(nameText);
    Button okButton = new Button("ok");
    userPanel.add(okButton);
    okButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ChatWidget.this.enterChatName(nameText, userDialog);
        }
    });
    userDialog.center();
    nameText.setFocus(true);
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.i18n.CwConstantsExample.java

License:Apache License

/**
 * Initialize this example./*from   w w  w . j av a2  s  .  c  o m*/
 */
@Override
public Widget onInitialize() {
    // Create the internationalized constants
    ExampleConstants exampleConstants = GWT.create(ExampleConstants.class);

    // Use a FlexTable to layout the content
    FlexTable layout = new FlexTable();
    FlexCellFormatter formatter = layout.getFlexCellFormatter();
    layout.setCellSpacing(5);

    // Add a link to the source code of the Interface
    HTML link = new HTML(" <a href=\"javascript:void(0);\">ExampleConstants</a>");
    link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            selectTab(2);
        }
    });
    HorizontalPanel linkPanel = new HorizontalPanel();
    linkPanel.setSpacing(3);
    linkPanel.add(new HTML(constants.cwConstantsExampleLinkText()));
    linkPanel.add(link);
    layout.setWidget(0, 0, linkPanel);
    formatter.setColSpan(0, 0, 2);

    // Show the first name
    TextBox firstNameBox = new TextBox();
    firstNameBox.setText("Amelie");
    firstNameBox.setWidth("17em");
    layout.setHTML(1, 0, exampleConstants.firstName());
    layout.setWidget(1, 1, firstNameBox);

    // Show the last name
    TextBox lastNameBox = new TextBox();
    lastNameBox.setText("Crutcher");
    lastNameBox.setWidth("17em");
    layout.setHTML(2, 0, exampleConstants.lastName());
    layout.setWidget(2, 1, lastNameBox);

    // Create a list box of favorite colors
    ListBox colorBox = new ListBox();
    Map<String, String> colorMap = exampleConstants.colorMap();
    for (Map.Entry<String, String> entry : colorMap.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        colorBox.addItem(value, key);
    }
    layout.setHTML(3, 0, exampleConstants.favoriteColor());
    layout.setWidget(3, 1, colorBox);

    // Return the layout Widget
    return layout;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.i18n.CwConstantsWithLookupExample.java

License:Apache License

/**
 * Initialize this example.//from  w w w . j  a  v  a 2  s  .  c  o  m
 */
@Override
public Widget onInitialize() {
    // Create the internationalized constants
    colorConstants = GWT.create(ColorConstants.class);

    // Use a FlexTable to layout the content
    FlexTable layout = new FlexTable();
    FlexCellFormatter formatter = layout.getFlexCellFormatter();
    layout.setCellSpacing(5);

    // Add a link to the source code of the Interface
    HTML link = new HTML(" <a href=\"javascript:void(0);\">ColorConstants</a>");
    link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            selectTab(2);
        }
    });
    HorizontalPanel linkPanel = new HorizontalPanel();
    linkPanel.setSpacing(3);
    linkPanel.add(new HTML(constants.cwConstantsWithLookupExampleLinkText()));
    linkPanel.add(link);
    layout.setWidget(0, 0, linkPanel);
    formatter.setColSpan(0, 0, 2);

    // Add a field so the user can type a color
    colorBox = new TextBox();
    colorBox.setText("red");
    colorBox.setWidth("17em");
    layout.setHTML(1, 0, constants.cwConstantsWithLookupExampleMethodName());
    layout.setWidget(1, 1, colorBox);

    // Show the last name
    colorResultsBox = new TextBox();
    colorResultsBox.setEnabled(false);
    colorResultsBox.setWidth("17em");
    layout.setHTML(2, 0, constants.cwConstantsWithLookupExampleResults());
    layout.setWidget(2, 1, colorResultsBox);

    // Add a handler to update the color as the user types a lookup value
    colorBox.addKeyUpHandler(new KeyUpHandler() {
        public void onKeyUp(KeyUpEvent event) {
            updateColor();
        }
    });

    // Return the layout Widget
    updateColor();
    return layout;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.i18n.CwMessagesExample.java

License:Apache License

/**
 * Initialize this example./*from ww w  .ja v a2  s  .com*/
 */
@Override
public Widget onInitialize() {
    // Create the internationalized error messages
    errorMessages = GWT.create(ErrorMessages.class);

    // Use a FlexTable to layout the content
    FlexTable layout = new FlexTable();
    FlexCellFormatter formatter = layout.getFlexCellFormatter();
    layout.setCellSpacing(5);

    // Add a link to the source code of the Interface
    HTML link = new HTML(" <a href=\"javascript:void(0);\">ErrorMessages</a>");
    link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            selectTab(2);
        }
    });
    HorizontalPanel linkPanel = new HorizontalPanel();
    linkPanel.setSpacing(3);
    linkPanel.add(new HTML(constants.cwMessagesExampleLinkText()));
    linkPanel.add(link);
    layout.setWidget(0, 0, linkPanel);
    formatter.setColSpan(0, 0, 2);

    // Show the template for reference
    String template = errorMessages.permissionDenied("{0}", "{1}", "{2}");
    layout.setHTML(1, 0, constants.cwMessagesExampleTemplateLabel());
    layout.setHTML(1, 1, template);

    // Add argument 0
    arg0Box = new TextBox();
    arg0Box.setText("amelie");
    layout.setHTML(2, 0, constants.cwMessagesExampleArg0Label());
    layout.setWidget(2, 1, arg0Box);

    // Add argument 1
    arg1Box = new TextBox();
    arg1Box.setText("guest");
    layout.setHTML(3, 0, constants.cwMessagesExampleArg1Label());
    layout.setWidget(3, 1, arg1Box);

    // Add argument 2
    arg2Box = new TextBox();
    arg2Box.setText("/secure/blueprints.xml");
    layout.setHTML(4, 0, constants.cwMessagesExampleArg2Label());
    layout.setWidget(4, 1, arg2Box);

    // Add the formatted message
    formattedMessage = new HTML();
    layout.setHTML(5, 0, constants.cwMessagesExampleFormattedLabel());
    layout.setWidget(5, 1, formattedMessage);
    formatter.setVerticalAlignment(5, 0, HasVerticalAlignment.ALIGN_TOP);

    // Add handlers to all of the argument boxes
    KeyUpHandler keyUpHandler = new KeyUpHandler() {
        public void onKeyUp(KeyUpEvent event) {
            updateMessage();
        }
    };
    arg0Box.addKeyUpHandler(keyUpHandler);
    arg1Box.addKeyUpHandler(keyUpHandler);
    arg2Box.addKeyUpHandler(keyUpHandler);

    // Return the layout Widget
    updateMessage();
    return layout;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.lists.CwListBox.java

License:Apache License

/**
 * Initialize this example./*from   w w  w. j av a2  s.  c o  m*/
 */
@Override
public Widget onInitialize() {
    // Create a panel to align the Widgets
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(20);

    // Add a drop box with the list types
    final ListBox dropBox = new ListBox(false);
    String[] listTypes = constants.cwListBoxCategories();
    for (int i = 0; i < listTypes.length; i++) {
        dropBox.addItem(listTypes[i]);
    }
    dropBox.ensureDebugId("cwListBox-dropBox");
    VerticalPanel dropBoxPanel = new VerticalPanel();
    dropBoxPanel.setSpacing(4);
    dropBoxPanel.add(new HTML(constants.cwListBoxSelectCategory()));
    dropBoxPanel.add(dropBox);
    hPanel.add(dropBoxPanel);

    // Add a list box with multiple selection enabled
    final ListBox multiBox = new ListBox(true);
    multiBox.ensureDebugId("cwListBox-multiBox");
    multiBox.setWidth("11em");
    multiBox.setVisibleItemCount(10);
    VerticalPanel multiBoxPanel = new VerticalPanel();
    multiBoxPanel.setSpacing(4);
    multiBoxPanel.add(new HTML(constants.cwListBoxSelectAll()));
    multiBoxPanel.add(multiBox);
    hPanel.add(multiBoxPanel);

    // Add a handler to handle drop box events
    dropBox.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            showCategory(multiBox, dropBox.getSelectedIndex());
            multiBox.ensureDebugId("cwListBox-multiBox");
        }
    });

    // Show default category
    showCategory(multiBox, 0);
    multiBox.ensureDebugId("cwListBox-multiBox");

    // Return the panel
    return hPanel;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.lists.CwStackPanel.java

License:Apache License

/**
 * Create the list of Contacts./*from   w  ww  . j  a  va 2  s  .  com*/
 * 
 * @param images the {@link Images} used in the Contacts
 * @return the list of contacts
 */
private VerticalPanel createContactsItem(Images images) {
    // Create a popup to show the contact info when a contact is clicked
    HorizontalPanel contactPopupContainer = new HorizontalPanel();
    contactPopupContainer.setSpacing(5);
    contactPopupContainer.add(images.defaultContact().createImage());
    final HTML contactInfo = new HTML();
    contactPopupContainer.add(contactInfo);
    final PopupPanel contactPopup = new PopupPanel(true, false);
    contactPopup.setWidget(contactPopupContainer);

    // Create the list of contacts
    VerticalPanel contactsPanel = new VerticalPanel();
    contactsPanel.setSpacing(4);
    String[] contactNames = constants.cwStackPanelContacts();
    String[] contactEmails = constants.cwStackPanelContactsEmails();
    for (int i = 0; i < contactNames.length; i++) {
        final String contactName = contactNames[i];
        final String contactEmail = contactEmails[i];
        final HTML contactLink = new HTML("<a href=\"javascript:undefined;\">" + contactName + "</a>");
        contactsPanel.add(contactLink);

        // Open the contact info popup when the user clicks a contact
        contactLink.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                // Set the info about the contact
                contactInfo.setHTML(contactName + "<br><i>" + contactEmail + "</i>");

                // Show the popup of contact info
                int left = contactLink.getAbsoluteLeft() + 14;
                int top = contactLink.getAbsoluteTop() + 14;
                contactPopup.setPopupPosition(left, top);
                contactPopup.show();
            }
        });
    }
    return contactsPanel;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.lists.CwStackPanel.java

License:Apache License

/**
 * Get a string representation of the header that includes an image and some
 * text.//from   ww w  .  ja  va2s  .com
 * 
 * @param text the header text
 * @param image the {@link AbstractImagePrototype} to add next to the header
 * @return the header as a string
 */
private String getHeaderString(String text, AbstractImagePrototype image) {
    // Add the image and text to a horizontal panel
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(0);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hPanel.add(image.createImage());
    HTML headerText = new HTML(text);
    headerText.setStyleName("cw-StackPanelHeader");
    hPanel.add(headerText);

    // Return the HTML string for the panel
    return hPanel.getElement().getString();
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.other.CwAnimation.java

License:Apache License

/**
 * Initialize this example.//www.j a v  a 2 s  .c om
 */
@Override
public Widget onInitialize() {
    // Create a new panel
    absolutePanel = new AbsolutePanel();
    absolutePanel.setSize("250px", "250px");
    absolutePanel.ensureDebugId("cwAbsolutePanel");

    // Add a widget that we will animate
    animateeTop = Showcase.images.gwtLogoThumb().createImage();
    animateeBottom = Showcase.images.gwtLogoThumb().createImage();
    animateeLeft = Showcase.images.gwtLogoThumb().createImage();
    animateeRight = Showcase.images.gwtLogoThumb().createImage();
    absolutePanel.add(animateeTop);
    absolutePanel.add(animateeBottom);
    absolutePanel.add(animateeLeft);
    absolutePanel.add(animateeRight);

    // Wrap the absolute panel in a DecoratorPanel
    DecoratorPanel absolutePanelWrapper = new DecoratorPanel();
    absolutePanelWrapper.setWidget(absolutePanel);

    // Create the options bar
    DecoratorPanel optionsWrapper = new DecoratorPanel();
    optionsWrapper.setWidget(createOptionsBar());

    // Add the components to a panel and return it
    HorizontalPanel mainLayout = new HorizontalPanel();
    mainLayout.setSpacing(10);
    mainLayout.add(optionsWrapper);
    mainLayout.add(absolutePanelWrapper);

    // Create the custom animation
    animation = new CustomAnimation();

    // Set the start position of the widgets
    animation.onComplete();

    // Return the layout
    return mainLayout;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.other.CwFrame.java

License:Apache License

/**
 * Initialize this example.//from w  ww  .  j a  v a  2s  .co m
 */
@Override
public Widget onInitialize() {
    // Create a new frame
    String url = GWT.getModuleBaseURL();
    final Frame frame = new Frame(url);
    frame.setSize("700px", "300px");
    frame.ensureDebugId("cwFrame");

    // Create a form to set the location of the frame
    final TextBox locationBox = new TextBox();
    locationBox.setText(url);
    Button setLocationButton = new Button(constants.cwFrameSetLocation());
    HorizontalPanel optionsPanel = new HorizontalPanel();
    optionsPanel.setSpacing(8);
    optionsPanel.add(locationBox);
    optionsPanel.add(setLocationButton);

    // Change the location when the user clicks the button
    setLocationButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            frame.setUrl(locationBox.getText());
        }
    });

    // Change the location when the user presses enter
    locationBox.addKeyDownHandler(new KeyDownHandler() {
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                frame.setUrl(locationBox.getText());
            }
        }

    });

    // Add everything to a panel and return it
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(optionsPanel);
    vPanel.add(frame);
    return vPanel;
}