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

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

Introduction

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

Prototype

public HorizontalPanel() 

Source Link

Document

Creates an empty horizontal panel.

Usage

From source file:com.google.gwt.sample.kitchensink.client.Buttons.java

License:Apache License

public Buttons() {
    HorizontalPanel hp;//from  w  w  w. j a  va  2s .  co m

    panel.add(hp = new HorizontalPanel());
    hp.setSpacing(8);
    hp.add(normalButton);
    hp.add(disabledButton);

    panel.add(hp = new HorizontalPanel());
    hp.setSpacing(8);
    hp.add(normalCheck);
    hp.add(disabledCheck);

    panel.add(hp = new HorizontalPanel());
    hp.setSpacing(8);
    hp.add(radio0);
    hp.add(radio1);
    hp.add(radio2);
    hp.add(radio3);

    disabledButton.setEnabled(false);
    disabledCheck.setEnabled(false);
    radio2.setEnabled(false);

    panel.setSpacing(8);
    initWidget(panel);
}

From source file:com.google.gwt.sample.kitchensink.client.Layouts.java

License:Apache License

public Layouts() {
    HTML contents = new HTML("This is a <code>ScrollPanel</code> contained at "
            + "the center of a <code>DockPanel</code>.  " + "By putting some fairly large contents "
            + "in the middle and setting its size explicitly, it becomes a "
            + "scrollable area within the page, but without requiring the use of " + "an IFRAME."
            + "Here's quite a bit more meaningless text that will serve primarily "
            + "to make this thing scroll off the bottom of its visible area.  "
            + "Otherwise, you might have to make it really, really small in order "
            + "to see the nifty scroll bars!");
    ScrollPanel scroller = new ScrollPanel(contents);
    scroller.setStyleName("ks-layouts-Scroller");

    DockPanel dock = new DockPanel();
    dock.setHorizontalAlignment(DockPanel.ALIGN_CENTER);
    HTML north0 = new HTML("This is the <i>first</i> north component", true);
    HTML east = new HTML("<center>This<br>is<br>the<br>east<br>component</center>", true);
    HTML south = new HTML("This is the south component");
    HTML west = new HTML("<center>This<br>is<br>the<br>west<br>component</center>", true);
    HTML north1 = new HTML("This is the <b>second</b> north component", true);
    dock.add(north0, DockPanel.NORTH);/*from   w  w w  .j ava  2 s.co m*/
    dock.add(east, DockPanel.EAST);
    dock.add(south, DockPanel.SOUTH);
    dock.add(west, DockPanel.WEST);
    dock.add(north1, DockPanel.NORTH);
    dock.add(scroller, DockPanel.CENTER);

    FlowPanel flow = new FlowPanel();
    for (int i = 0; i < 8; ++i)
        flow.add(new CheckBox("Flow " + i));

    HorizontalPanel horz = new HorizontalPanel();
    horz.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    horz.add(new Button("Button"));
    horz.add(new HTML("<center>This is a<br>very<br>tall thing</center>", true));
    horz.add(new Button("Button"));

    VerticalPanel vert = new VerticalPanel();
    vert.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vert.add(new Button("Small"));
    vert.add(new Button("--- BigBigBigBig ---"));
    vert.add(new Button("tiny"));

    MenuBar menu = new MenuBar();
    MenuBar menu0 = new MenuBar(true), menu1 = new MenuBar(true);
    menu.addItem("menu0", menu0);
    menu.addItem("menu1", menu1);
    menu0.addItem("child00", (Command) null);
    menu0.addItem("child01", (Command) null);
    menu0.addItem("child02", (Command) null);
    menu1.addItem("child10", (Command) null);
    menu1.addItem("child11", (Command) null);
    menu1.addItem("child12", (Command) null);

    String id = HTMLPanel.createUniqueId();
    HTMLPanel html = new HTMLPanel("This is an <code>HTMLPanel</code>.  It allows you to add "
            + "components inside existing HTML, like this:" + "<span id='" + id + "'></span>"
            + "Notice how the menu just fits snugly in there?  Cute.");
    DOM.setStyleAttribute(menu.getElement(), "display", "inline");
    html.add(menu, id);

    VerticalPanel panel = new VerticalPanel();
    panel.setSpacing(8);
    panel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    panel.add(makeLabel("Dock Panel"));
    panel.add(dock);
    panel.add(makeLabel("Flow Panel"));
    panel.add(flow);
    panel.add(makeLabel("Horizontal Panel"));
    panel.add(horz);
    panel.add(makeLabel("Vertical Panel"));
    panel.add(vert);
    panel.add(makeLabel("HTML Panel"));
    panel.add(html);

    initWidget(panel);
    setStyleName("ks-layouts");
}

From source file:com.google.gwt.sample.kitchensink.client.Lists.java

License:Apache License

public Lists() {
    combo.setVisibleItemCount(1);//from w  w  w  . j  a  v a  2  s.com
    combo.addChangeListener(this);
    list.setVisibleItemCount(10);
    list.setMultipleSelect(true);

    for (int i = 0; i < sStrings.length; ++i)
        combo.addItem("List " + i);
    combo.setSelectedIndex(0);
    fillList(0);

    list.addChangeListener(this);

    HorizontalPanel horz = new HorizontalPanel();
    horz.setVerticalAlignment(HorizontalPanel.ALIGN_TOP);
    horz.setSpacing(8);
    horz.add(combo);
    horz.add(list);

    VerticalPanel panel = new VerticalPanel();
    panel.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);
    panel.add(horz);
    panel.add(echo);
    initWidget(panel);

    echoSelection();
}

From source file:com.google.gwt.sample.kitchensink.client.Text.java

License:Apache License

private Widget createTextThing(final TextBoxBase textBox) {
    HorizontalPanel p = new HorizontalPanel();
    p.setSpacing(4);// ww w  .j  av a 2  s  .  c o m

    p.add(textBox);

    final HTML echo = new HTML();
    p.add(new Button("select all", new ClickListener() {
        public void onClick(Widget sender) {
            textBox.selectAll();
            textBox.setFocus(true);
            updateText(textBox, echo);
        }
    }));

    p.add(echo);
    textBox.addKeyboardListener(new KeyboardListenerAdapter() {
        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            updateText(textBox, echo);
        }
    });

    textBox.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            updateText(textBox, echo);
        }
    });

    return p;
}

From source file:com.google.gwt.sample.showcase.client.Application.java

License:Apache License

/**
 * Constructor./* w  w w  . j  a v  a  2s  .c o  m*/
 */
public Application() {
    // Setup the main layout widget
    FlowPanel layout = new FlowPanel();
    initWidget(layout);

    // Setup the top panel with the title and links
    createTopPanel();
    layout.add(topPanel);

    // Add the main menu
    bottomPanel = new HorizontalPanel();
    bottomPanel.setWidth("100%");
    bottomPanel.setSpacing(0);
    bottomPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    layout.add(bottomPanel);
    createMainMenu();
    bottomPanel.add(mainMenu);

    // Setup the content layout
    contentLayout = new Grid(2, 1);
    contentLayout.setCellPadding(0);
    contentLayout.setCellSpacing(0);
    contentDecorator = new DecoratorPanel();
    contentDecorator.setWidget(contentLayout);
    contentDecorator.addStyleName(DEFAULT_STYLE_NAME + "-content-decorator");
    bottomPanel.add(contentDecorator);
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_LEFT);
        contentDecorator.getElement().setAttribute("align", "LEFT");
    } else {
        bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_RIGHT);
        contentDecorator.getElement().setAttribute("align", "RIGHT");
    }
    CellFormatter formatter = contentLayout.getCellFormatter();

    // Add the content title
    setContentTitle(new HTML("Content"));
    formatter.setStyleName(0, 0, DEFAULT_STYLE_NAME + "-content-title");

    // Add the content wrapper
    contentWrapper = new SimplePanel();
    contentLayout.setWidget(1, 0, contentWrapper);
    formatter.setStyleName(1, 0, DEFAULT_STYLE_NAME + "-content-wrapper");
    setContent(null);

    // Add a window resize handler
    Window.addResizeHandler(this);
}

From source file:com.google.gwt.sample.showcase.client.content.i18n.CwBidiFormatting.java

License:Apache License

/**
 * Initialize this example./*from  w w  w . j a va 2s .  c o m*/
 */
@ShowcaseSource
@Override
public Widget onInitialize() {
    // Create the internationalized blog messages
    blogMessages = GWT.create(BlogMessages.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
    final String rawFile = getSimpleName(BlogMessages.class);
    Anchor link = new Anchor(rawFile);
    link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            fireRawSourceRequest(rawFile + ".java");
        }
    });
    HorizontalPanel linkPanel = new HorizontalPanel();
    linkPanel.setSpacing(3);
    linkPanel.add(new HTML(constants.cwBidiFormattingLinkText()));
    linkPanel.add(link);
    layout.setWidget(0, 0, linkPanel);
    formatter.setColSpan(0, 0, 2);

    // Show the template for reference
    String template = blogMessages.userComment("{0}", "{1}", "{2}");
    layout.setHTML(1, 0, constants.cwBidiFormattingTemplateLabel());
    layout.setHTML(1, 1, template);

    // Add argument 0
    arg0Box = new TextBox();
    // Using an initial value whose direction is opposite the locale's direction
    // demonstrates the need for and effect of bidi formatting.
    arg0Box.setText(LocaleInfo.getCurrentLocale().isRTL() ? "Tom Bombadil" : " ");
    layout.setHTML(2, 0, constants.cwBidiFormattingArg0Label());
    layout.setWidget(2, 1, arg0Box);

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

    // Add argument 2
    arg2Box = new TextBox();
    // Using an initial value whose direction is opposite the locale's direction
    // demonstrates the need for and effect of bidi formatting.
    arg2Box.setText(
            LocaleInfo.getCurrentLocale().isRTL() ? "How deep is your love?" : "   ?");
    layout.setHTML(4, 0, constants.cwBidiFormattingArg2Label());
    layout.setWidget(4, 1, arg2Box);

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

    // Add the bidi formatted message
    bidiFormattedMessage = new HTML();
    layout.setHTML(6, 0, constants.cwBidiFormattingBidiFormattedLabel());
    layout.setWidget(6, 1, bidiFormattedMessage);
    formatter.setVerticalAlignment(6, 0, HasVerticalAlignment.ALIGN_TOP);

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

    // Return the layout Widget
    updateMessages();

    return layout;
}

From source file:com.google.gwt.sample.showcase.client.content.i18n.CwConstantsExample.java

License:Apache License

/**
 * Initialize this example./*from   w w w . ja  v a2  s.  com*/
 */
@ShowcaseSource
@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
    final String rawFile = getSimpleName(ExampleConstants.class);
    Anchor link = new Anchor(rawFile);
    link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            fireRawSourceRequest(rawFile + ".java");
        }
    });
    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:com.google.gwt.sample.showcase.client.content.i18n.CwConstantsWithLookupExample.java

License:Apache License

/**
 * Initialize this example./* w w  w.j a va  2  s  .c o  m*/
 */
@ShowcaseSource
@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
    final String rawFile = getSimpleName(ColorConstants.class);
    Anchor link = new Anchor(rawFile);
    link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            fireRawSourceRequest(rawFile + ".java");
        }
    });
    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:com.google.gwt.sample.showcase.client.content.i18n.CwMessagesExample.java

License:Apache License

/**
 * Initialize this example./*from w  w  w. j av a  2  s  .  c  o  m*/
 */
@ShowcaseSource
@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
    final String rawFile = getSimpleName(ErrorMessages.class);
    Anchor link = new Anchor(rawFile);
    link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            fireRawSourceRequest(rawFile + ".java");
        }
    });
    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:com.google.gwt.sample.showcase.client.content.i18n.CwPluralFormsExample.java

License:Apache License

/**
 * Initialize this example./*from w ww.j  a va  2  s .  co  m*/
 */
@ShowcaseSource
@Override
public Widget onInitialize() {
    // Create the internationalized error messages
    pluralMessages = GWT.create(PluralMessages.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
    final String rawFile = getSimpleName(PluralMessages.class);
    Anchor link = new Anchor(rawFile);
    link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            fireRawSourceRequest(rawFile + ".java");
        }
    });
    HorizontalPanel linkPanel = new HorizontalPanel();
    linkPanel.setSpacing(3);
    linkPanel.add(new HTML(constants.cwPluralFormsExampleLinkText()));
    linkPanel.add(link);
    layout.setWidget(0, 0, linkPanel);
    formatter.setColSpan(0, 0, 2);

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

    // Add the formatted message
    formattedMessage = new Label();
    layout.setHTML(5, 0, constants.cwPluralFormsExampleFormattedLabel());
    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);

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