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.gwtai.demo.client.StopWatchAppletTab.java
License:Apache License
public StopWatchAppletTab() { VerticalPanel panelMain = new VerticalPanel(); panelMain.setWidth("100%"); panelMain.setSpacing(4);//from w ww . j av a2 s . c o m VerticalPanel panelLaps = new VerticalPanel(); panelLaps.setWidth("100%"); panelLaps.setSpacing(4); Button buttonStart = new Button("Start"); Button buttonStop = new Button("Stop"); final StopWatchApplet stopWatchApplet = (StopWatchApplet) GWT.create(StopWatchApplet.class); buttonStart.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { stopWatchApplet.startWatch(); } }); buttonStop.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { stopWatchApplet.stopWatch(); } }); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setSpacing(4); buttonPanel.add(buttonStart); buttonPanel.add(buttonStop); Widget widgetApplet = AppletJSUtil.createAppletWidget(stopWatchApplet); AppletJSUtil.registerAppletCallback(stopWatchApplet, new StopWatchCallback(panelLaps)); Label labelTitle = new Label( "Register a callback object to notify GWT of changes from within the Applet code."); DisclosurePanel panelCode = new DisclosurePanel("View code"); panelCode.setWidth("100%"); panelCode.setAnimationEnabled(true); panelCode.setContent(createCodeHTML()); panelMain.add(labelTitle); panelMain.add(widgetApplet); panelMain.add(buttonPanel); panelMain.add(panelLaps); panelMain.add(panelCode); panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(panelLaps, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(buttonPanel, VerticalPanel.ALIGN_CENTER); initWidget(panelMain); }
From source file:com.google.gwt.gwtai.demo.client.TrayIconAppletTab.java
License:Apache License
public TrayIconAppletTab() { VerticalPanel panelMain = new VerticalPanel(); panelMain.setWidth("100%"); panelMain.setSpacing(4);//w w w.j a va 2 s . com _trayIconApplet = (TrayIconApplet) GWT.create(TrayIconApplet.class); Widget widgetApplet = AppletJSUtil.createAppletWidget(_trayIconApplet); Label labelTitle = new Label( "Hook into the desktop tray from a GWT application. This is a 'Proof of Concept', the feature is not finished yet."); DisclosurePanel panelCode = new DisclosurePanel("View code"); panelCode.setWidth("100%"); panelCode.setAnimationEnabled(true); panelCode.setContent(createCodeHTML()); HorizontalPanel panelItems = new HorizontalPanel(); panelItems.setSpacing(4); final TextBox boxCaption = new TextBox(); final ListBox boxItemType = new ListBox(); boxItemType.addItem("Text"); boxItemType.addItem("CheckBox"); boxItemType.setSelectedIndex(0); Button buttonAdd = new Button("Add menu item"); buttonAdd.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String caption = boxCaption.getText(); if (null == caption || caption.length() < 1) { Window.alert("Caption can not be empty"); } else { String itemType = boxItemType.getItemText(boxItemType.getSelectedIndex()); if (itemType.equals("CheckBox")) { _trayIconApplet.addCheckBoxItem(caption); } else { _trayIconApplet.addTextItem(caption); } } } }); Button buttonSeparator = new Button("Add separator"); buttonSeparator.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { _trayIconApplet.addSeparator(); } }); panelItems.add(boxCaption); panelItems.add(boxItemType); panelItems.add(buttonAdd); panelItems.add(buttonSeparator); panelMain.add(labelTitle); panelMain.add(widgetApplet); panelMain.add(panelItems); panelMain.add(panelCode); panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER); initWidget(panelMain); }
From source file:com.google.gwt.inject.example.simple.client.SimpleWidget.java
License:Apache License
/** * Constructs a new simple widget.//from w ww .ja v a2 s . com * * @param messages a message interface providing message and error templates * @param service a service that returns fresh messages and errors * @param constants constants to label the buttons */ @Inject public SimpleWidget(SimpleMessages messages, SimpleService service, SimpleConstants constants, AsyncProvider<SimpleAsyncWidget> asyncWidgetProvider) { this.messages = messages; this.service = service; this.asyncWidgetProvider = asyncWidgetProvider; text = new Label(); text.addStyleName("message"); Button showMessage = new Button(constants.showMessage(), new ClickHandler() { public void onClick(ClickEvent event) { showMessage(); } }); Button showError = new Button(constants.showError(), new ClickHandler() { public void onClick(ClickEvent event) { showError(); } }); Button showAsync = new Button(constants.showMessageForAsync(), new ClickHandler() { public void onClick(ClickEvent event) { showAsync(); } }); HorizontalPanel buttons = new HorizontalPanel(); buttons.add(showMessage); buttons.add(showError); buttons.add(showAsync); VerticalPanel root = new VerticalPanel(); root.add(text); root.add(buttons); root.addStyleName("simple"); initWidget(root); }
From source file:com.google.gwt.language.sample.hellolanguage.client.LanguageDetectionDemo.java
License:Apache License
/** * Creates a demo panel.//www .j a v a 2 s .c o m * * @return demo panel */ private VerticalPanel createDemoPanel() { VerticalPanel demoPanel = new VerticalPanel(); demoPanel.add(new Label("Enter text:")); demoPanel.add(inputTextArea); HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setSpacing(10); hPanel.add(createLanguageDetectionButton()); hPanel.add(new Label(">>")); hPanel.add(outputDiv); demoPanel.add(hPanel); return demoPanel; }
From source file:com.google.gwt.language.sample.hellolanguage.client.TranslationDemo.java
License:Apache License
/** * Creates translation control panel containing list boxes for source and * destination languages, and a button to translate. * * @return panel containing controls/* www. j a v a 2 s .c om*/ */ private HorizontalPanel createTranslationControlPanel() { populateListBoxes(); HorizontalPanel listBoxesPanel = new HorizontalPanel(); listBoxesPanel.add(sourceLanguages); listBoxesPanel.add(new Label(">>")); listBoxesPanel.add(destinationLanguages); Button translateButton = createTranslateButton(); HorizontalPanel controlPanel = new HorizontalPanel(); controlPanel.setSpacing(10); controlPanel.setWidth("100%"); controlPanel.add(listBoxesPanel); controlPanel.add(translateButton); controlPanel.setCellHorizontalAlignment(translateButton, HasHorizontalAlignment.ALIGN_RIGHT); return controlPanel; }
From source file:com.google.gwt.maps.sample.hellomaps.client.CustomControlDemo.java
License:Apache License
public CustomControlDemo() { VerticalPanel vertPanel = new VerticalPanel(); vertPanel.setStyleName("hm-panel"); actionListBox = new ListBox(); for (ControlDemos cd : ControlDemos.values()) { actionListBox.addItem(cd.valueOf()); }/*from w ww .j a v a 2 s . c o m*/ actionListBox.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { displayCustomControl(); } }); HorizontalPanel horizPanel = new HorizontalPanel(); horizPanel.add(new Label("Choose Action:")); horizPanel.add(actionListBox); horizPanel.setSpacing(10); vertPanel.add(horizPanel); map = new MapWidget(LatLng.newInstance(37.441944, -122.141944), 13); map.setSize("500px", "300px"); map.addMapType(MapType.getNormalMap()); map.addMapType(MapType.getSatelliteMap()); map.addMapType(MapType.getMarsVisibleMap()); map.addMapType(MapType.getMarsElevationMap()); map.addMapType(MapType.getMarsInfraredMap()); vertPanel.add(map); new Timer() { public void run() { displayCustomControl(); } }.schedule(250); initWidget(vertPanel); }
From source file:com.google.gwt.maps.sample.hellomaps.client.DrawingOverlayDemo.java
License:Apache License
/** * Create the toolbar above the map. Note that the map must be initialized * before this method is called.// w w w. j av a 2 s.c o m */ private Widget makeToolbar() { DockPanel p = new DockPanel(); p.setWidth("100%"); HorizontalPanel buttonPanel = new HorizontalPanel(); Button addButton = new Button("Draw new object"); addButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (addPolyDialog == null) { addPolyDialog = makeAddPolyDialog(); } addPolyDialog.center(); addPolyDialog.show(); if (lastPolygon != null) { lastPolygon.setEditingEnabled(false); } if (lastPolyline != null) { lastPolyline.setEditingEnabled(false); } } }); buttonPanel.add(addButton); editPolylineButton.setEnabled(false); editPolylineButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { editPolyline(); } }); buttonPanel.add(editPolylineButton); editPolygonButton.setEnabled(false); editPolygonButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { editPolygon(); } }); buttonPanel.add(editPolygonButton); p.add(buttonPanel, DockPanel.EAST); return p; }
From source file:com.google.gwt.maps.sample.hellomaps.client.DrawingOverlayDemo.java
License:Apache License
private DialogBox makeAddPolyDialog() { DialogBox dialog = new DialogBox(); dialog.setTitle("Add Polyline"); Grid grid = new Grid(2, 4); VerticalPanel vp = new VerticalPanel(); grid.setHTML(0, 0, "<b>Opacity</b>"); // The drop down lists for setting the style final ListBox opacityBox = new ListBox(); for (int i = 100; i > 0; i -= 10) { opacityBox.addItem(i + "%"); }/*from w ww . j a va 2 s . c om*/ opacityBox.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { String val = opacityBox.getItemText(opacityBox.getSelectedIndex()); opacity = Double.parseDouble(val.replace("%", "")) / 100.0; } }); grid.setWidget(1, 0, opacityBox); grid.setHTML(0, 1, "<b>Weight</b>"); final ListBox weightBox = new ListBox(); weightBox.addItem("1 pixel"); weightBox.addItem("2 pixels"); weightBox.addItem("3 pixels"); weightBox.addItem("5 pixels"); weightBox.addItem("10 pixels"); weightBox.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { String val = weightBox.getItemText(weightBox.getSelectedIndex()); val = val.replace(" pixel", ""); val = val.replace("s", ""); weight = Integer.parseInt(val); } }); grid.setWidget(1, 1, weightBox); grid.setHTML(0, 2, "<b>Color</b>"); final ListBox colorBox = new ListBox(); colorBox.addItem("#FF0000 red"); colorBox.addItem("#FFFF00 yellow"); colorBox.addItem("#00FF00 green"); colorBox.addItem("#00FFFF cyan"); colorBox.addItem("#0000FF blue"); colorBox.addItem("#FF00FF violet"); colorBox.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { color = colorBox.getItemText(colorBox.getSelectedIndex()).substring(0, 7); } }); grid.setWidget(1, 2, colorBox); grid.setHTML(0, 3, "<b>Fill Polygon</b>"); final CheckBox fillCheckBox = new CheckBox(""); fillCheckBox.addClickListener(new ClickListener() { public void onClick(Widget sender) { fillFlag = fillCheckBox.isChecked(); } }); grid.setWidget(1, 3, fillCheckBox); Button addPolylineButton = new Button("Make Polyline"); addPolylineButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { message1.setText("opacity=" + opacity + " color=" + color + " weight=" + weight + " polygon=" + makePolygon + " center=" + map.getCenter() + " zoom=" + map.getZoomLevel()); addPolyDialog.hide(); createPolyline(); editPolylineButton.setEnabled(true); } }); Button addPolygonButton = new Button("Make Polygon"); addPolygonButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { message1.setText( "Opacity=" + opacity + " color=" + color + "weight=" + weight + "polygon = " + makePolygon + "Center=" + map.getCenter() + " zoom=" + map.getZoomLevel() + "fill=" + fillFlag); addPolyDialog.hide(); createPolygon(); editPolygonButton.setEnabled(true); } }); Button cancelButton = new Button("Cancel"); cancelButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { addPolyDialog.hide(); } }); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); buttonPanel.add(addPolylineButton); buttonPanel.add(addPolygonButton); buttonPanel.add(cancelButton); vp.add(grid); vp.add(buttonPanel); dialog.add(vp); return dialog; }
From source file:com.google.gwt.maps.sample.hellomaps.client.GeocoderDemo.java
License:Apache License
private Panel buildLatLngPanel() { HorizontalPanel horiz = new HorizontalPanel(); horiz.add(new Label("Lat:")); latLabel = new Label(); horiz.add(latLabel);/* w w w .java 2 s. co m*/ horiz.add(new Label("Long:")); lngLabel = new Label(); horiz.add(lngLabel); horiz.setSpacing(10); return horiz; }
From source file:com.google.gwt.maps.sample.hellomaps.client.HelloMaps.java
License:Apache License
public void onModuleLoad() { if (!Maps.isLoaded()) { Window.alert("The Maps API is not installed." + " The <script> tag that loads the Maps API may be missing or your Maps key may be wrong."); return;//from w w w. j av a2 s. c o m } if (!Maps.isBrowserCompatible()) { Window.alert("The Maps API is not compatible with this browser."); return; } // Load all the MapsDemos. loadMapsDemos(); innerPanel.setStylePrimaryName("hm-mapinnerpanel"); innerPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); HorizontalPanel horizPanel = new HorizontalPanel(); list.setStylePrimaryName("hm-demolistbox"); horizPanel.add(new Label("Select Demo: ")); horizPanel.add(list); innerPanel.add(horizPanel); innerPanel.add(description); innerPanel.setSpacing(10); History.addHistoryListener(this); outerPanel.setStylePrimaryName("hm-outerpanel"); outerPanel.insertRow(0); outerPanel.insertRow(0); outerPanel.insertRow(0); outerPanel.insertRow(0); outerPanel.insertRow(0); outerPanel.addCell(0); outerPanel.addCell(1); outerPanel.addCell(2); outerPanel.addCell(3); outerPanel.addCell(4); outerPanel.setWidget(0, 0, new HTML("This Maps-enabled application was built using the Google " + "API Library for GWT, " + "<a href=\"http://code.google.com/p/gwt-google-apis/\">" + "http://code.google.com/p/gwt-google-apis/</a>. " + "The drop down list below allows you to select a scenario that " + "demonstrates a particular capability of the Maps support.")); outerPanel.setWidget(1, 0, innerPanel); DecoratorPanel decorator = new DecoratorPanel(); decorator.add(outerPanel); RootPanel.get("hm-map").add(decorator); // Show the initial screen. String initToken = History.getToken(); if (initToken.length() > 0) { onHistoryChanged(initToken); } else { showInfo(); } }