List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setSpacing
public void setSpacing(int spacing)
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 w w. j a va2s. c om*/ 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 av a 2 s . c om*/ _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.language.sample.hellolanguage.client.LanguageDetectionDemo.java
License:Apache License
/** * Creates a demo panel./* w w w . 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// w w w . j a v a2 s . c o m */ 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 w w .jav a 2s.com 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.GeocoderDemo.java
License:Apache License
private Panel buildLatLngPanel() { HorizontalPanel horiz = new HorizontalPanel(); horiz.add(new Label("Lat:")); latLabel = new Label(); horiz.add(latLabel);//from www . j a v a2 s . c om 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.InfoWindowDemo.java
License:Apache License
public InfoWindowDemo() { VerticalPanel vertPanel = new VerticalPanel(); vertPanel.setStyleName("hm-panel"); map = new MapWidget(ATLANTA, 13); vertPanel.add(map);/*from w ww . java 2s .co m*/ actionListBox = new ListBox(); actionListBox.addItem(TEST_DEFAULT); actionListBox.addItem(TEST_IMAGE); actionListBox.addItem(TEST_NO_CLICK); actionListBox.addItem(TEST_TABS); actionListBox.addItem(TEST_MAX_CONTENT); actionListBox.addItem(TEST_MAX_TITLE_CONTENT_WIDGET); actionListBox.addItem(TEST_MAP_BLOWUP); actionListBox.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { displayInfoWindow(); } }); map.setSize("500px", "450px"); HorizontalPanel horizPanel = new HorizontalPanel(); horizPanel.add(new Label("Choose Action:")); horizPanel.add(actionListBox); horizPanel.setSpacing(10); vertPanel.add(horizPanel); vertPanel.add(map); initWidget(vertPanel); }
From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java
License:Apache License
/** * Create a panel of buttons to use to perform various actions on the marker. *//*from w w w .ja v a 2s. c o m*/ private Panel createActionButtons() { VerticalPanel vp = new VerticalPanel(); HorizontalPanel hp = new HorizontalPanel(); hp.setSpacing(10); vp.add(hp); // Create a button to hide/show the marker final Button hideButton = new Button("Hide Marker"); hideButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { boolean state = !marker.isVisible(); marker.setVisible(state); if (state) { hideButton.setText("Hide Marker"); } else { hideButton.setText("Show Marker"); } } }); hp.add(hideButton); // Create a button to remove the marker from the map. final Button removeButton = new Button("Remove Marker"); removeButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (!markerRemoved) { map.removeOverlay(marker); removeButton.setText("Add Marker"); } else { map.addOverlay(marker); removeButton.setText("Remove Marker"); } hideButton.setEnabled(markerRemoved); markerRemoved = !markerRemoved; } }); hp.add(removeButton); // Create a button to hide/show the polygon final Button hidePolygonButton = new Button("Hide Polygon"); hidePolygonButton.setEnabled(false); hidePolygonButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { boolean state = !polygon.isVisible(); polygon.setVisible(state); if (state) { hidePolygonButton.setText("Hide Polygon"); } else { hidePolygonButton.setText("Show Polygon"); } } }); hp.add(hidePolygonButton); // Create a button to remove the polygon from the map. final Button removePolygonButton = new Button("Add Polygon"); removePolygonButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (!polygonRemoved) { map.removeOverlay(polygon); removePolygonButton.setText("Add Polygon"); } else { map.addOverlay(polygon); removePolygonButton.setText("Remove Polygon"); } hidePolygonButton.setEnabled(polygonRemoved); polygonRemoved = !polygonRemoved; } }); hp.add(removePolygonButton); // Create a button to hide/show the polyline final Button hidePolylineButton = new Button("Hide Polyline"); hidePolylineButton.setEnabled(false); hidePolylineButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { boolean state = !polyline.isVisible(); polyline.setVisible(state); if (state) { hidePolylineButton.setText("Hide Polyline"); } else { hidePolylineButton.setText("Show Polyline"); } } }); hp.add(hidePolylineButton); // Create a button to remove the polyline from the map. final Button removePolylineButton = new Button("Add Polyline"); removePolylineButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (!polylineRemoved) { map.removeOverlay(polyline); removePolylineButton.setText("Add Polyline"); } else { map.addOverlay(polyline); removePolylineButton.setText("Remove Polyline"); } hidePolylineButton.setEnabled(polylineRemoved); polylineRemoved = !polylineRemoved; } }); hp.add(removePolylineButton); final Button clearOverlaysButton = new Button("Clear Overlays"); clearOverlaysButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { map.clearOverlays(); } }); hp.add(clearOverlaysButton); hp = new HorizontalPanel(); hp.setSpacing(10); vp.add(hp); final Button infoWindowButton = new Button("Show InfoWindow"); infoWindowButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { InfoWindow info = map.getInfoWindow(); InfoWindowContent content = new InfoWindowContent("Hello Maps!"); content.setMaxContent("Hello Maps - more content"); content.setMaxTitle("Hello Maps"); info.open(map.getCenter(), content); } }); hp.add(infoWindowButton); final Button mInfoWindowButton = new Button("Marker InfoWindow"); mInfoWindowButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { InfoWindow info = map.getInfoWindow(); InfoWindowContent content = new InfoWindowContent("Hello Maps!"); content.setMaxContent("Hello Maps - more content"); content.setMaxTitle("Hello Maps"); info.open(marker, content); } }); hp.add(mInfoWindowButton); final Button mapTypeButton = new Button("Add Map Type"); mapTypeButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (!mapTypeRemoved) { map.addMapType(MapType.getSkyVisibleMap()); mapTypeButton.setText("Remove MapType"); } else { map.removeMapType(MapType.getSkyVisibleMap()); mapTypeButton.setText("Add MapType"); } mapTypeRemoved = !mapTypeRemoved; } }); hp.add(mapTypeButton); // Create a button to clear out the table. final Button clearTableButton = new Button("Clear Table"); clearTableButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { clearListenerTable(); } }); hp.add(clearTableButton); return vp; }
From source file:com.google.gwt.maps.sample.hellomaps.client.OverlayDemo.java
License:Apache License
public OverlayDemo() { VerticalPanel vertPanel = new VerticalPanel(); vertPanel.setStyleName("hm-panel"); actionListBox = new ListBox(); for (OverlayDemos od : OverlayDemos.values()) { actionListBox.addItem(od.valueOf()); }/*from ww w .j a v a 2 s .c o m*/ actionListBox.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { displayOverlay(); } }); 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.4419, -122.1419), 13); map.setSize("500px", "300px"); map.addControl(new SmallMapControl()); map.addControl(new MapTypeControl()); vertPanel.add(map); initWidget(vertPanel); }
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); hp.add(normalButton);/* www. jav a 2 s . co m*/ 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); }