List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setSpacing
public void setSpacing(int spacing)
From source file:com.google.gwt.sample.kitchensink.client.Lists.java
License:Apache License
public Lists() { combo.setVisibleItemCount(1);/*from w ww .j av a 2s. c om*/ 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); p.add(textBox);/*from w w w . j av a2 s. c o m*/ 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.content.i18n.CwBidiFormatting.java
License:Apache License
/** * Initialize this example.//from w w w. j a v a 2 s . c om */ @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 a 2 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.// www . j av a 2 s. co 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 ww . j a v 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 w w. jav a 2 s.c om */ @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; }
From source file:com.google.gwt.sample.showcase.client.content.lists.CwListBox.java
License:Apache License
/** * Initialize this example./* www. j a v a 2 s . c o m*/ */ @ShowcaseSource @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:com.google.gwt.sample.showcase.client.content.lists.CwStackLayoutPanel.java
License:Apache License
/** * Create the list of Contacts./* ww w. j a v a 2s .c o m*/ * * @param images the {@link Images} used in the Contacts * @return the list of contacts */ @ShowcaseSource private Widget 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(new Image(images.defaultContact())); 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.cwStackLayoutPanelContacts(); String[] contactEmails = constants.cwStackLayoutPanelContactsEmails(); for (int i = 0; i < contactNames.length; i++) { final String contactName = contactNames[i]; final String contactEmail = contactEmails[i]; final Anchor contactLink = new Anchor(contactName); 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 SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendEscaped(contactName); sb.appendHtmlConstant("<br><i>"); sb.appendEscaped(contactEmail); sb.appendHtmlConstant("</i>"); contactInfo.setHTML(sb.toSafeHtml()); // Show the popup of contact info int left = contactLink.getAbsoluteLeft() + 14; int top = contactLink.getAbsoluteTop() + 14; contactPopup.setPopupPosition(left, top); contactPopup.show(); } }); } return new SimplePanel(contactsPanel); }
From source file:com.google.gwt.sample.showcase.client.content.lists.CwStackLayoutPanel.java
License:Apache License
/** * Create a widget to display in the header that includes an image and some * text.//from w w w. j a v a 2s. com * * @param text the header text * @param image the {@link ImageResource} to add next to the header * @return the header widget */ @ShowcaseSource private Widget createHeaderWidget(String text, ImageResource image) { // Add the image and text to a horizontal panel HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setHeight("100%"); hPanel.setSpacing(0); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hPanel.add(new Image(image)); HTML headerText = new HTML(text); headerText.setStyleName("cw-StackPanelHeader"); hPanel.add(headerText); return new SimplePanel(hPanel); }