List of usage examples for com.google.gwt.user.client.ui HorizontalPanel add
@Override public void add(Widget w)
From source file:com.google.gwt.sample.expenses.client.DenialPopup.java
License:Apache License
public DenialPopup() { super(false, true); setStyleName(Styles.common().popupPanel()); setGlassEnabled(true);// w w w . jav a 2 s. com confirmButton.setWidth("11ex"); cancelButton.setWidth("11ex"); reasonBox.getElement().getStyle().setMarginLeft(10.0, Unit.PX); reasonBox.getElement().getStyle().setMarginRight(10.0, Unit.PX); HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hPanel.add(new HTML("<b>Reason:</b>")); hPanel.add(reasonBox); hPanel.add(confirmButton); hPanel.add(cancelButton); setWidget(hPanel); cancelButton.getElement().getParentElement().getStyle().setPaddingLeft(5.0, Unit.PX); }
From source file:com.google.gwt.sample.hellomaps.client.HelloMaps.java
License:Apache License
private void createMap() { // Set the map up in a Dialog box, just for fun. final DialogBox dialog = new DialogBox(false, false); final Map theMap = new Map(); final Button findButton = new Button("Address:"); final TextBox tb = new TextBox(); tb.addKeyboardListener(new KeyboardListenerAdapter() { @Override/*from w ww. j av a2 s.c om*/ public void onKeyPress(Widget sender, char keyCode, int modifiers) { if (keyCode == KEY_ENTER) { theMap.setLocation(((TextBox) sender).getText()); } else if (keyCode == KEY_ESCAPE) { dialog.removeFromParent(); } } }); findButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { theMap.setLocation(tb.getText()); } }); tb.setWidth("100%"); final HorizontalPanel hp = new HorizontalPanel(); hp.add(findButton); hp.setCellWidth(findButton, "15%"); hp.add(tb); hp.setCellWidth(tb, "85%"); final VerticalPanel vp = new VerticalPanel(); vp.add(hp); vp.add(theMap); dialog.setText("Drag me!"); dialog.setWidget(vp); dialog.center(); }
From source file:com.google.gwt.sample.kitchensink.client.Buttons.java
License:Apache License
public Buttons() { HorizontalPanel hp; panel.add(hp = new HorizontalPanel()); hp.setSpacing(8);/*from w w w . j av a 2 s. c o m*/ 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);/*w w w . ja v a2 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 va2 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);//from w w w . j a va 2s . c om 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.content.i18n.CwBidiFormatting.java
License:Apache License
/** * Initialize this example.//from ww w . jav a 2 s .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 va2s . c o m*/ */ @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.//from w w w. j ava2s .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./*ww w .j a va2 s . c om*/ */ @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; }