List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:com.google.gwt.maps.sample.hellomaps.client.InfoWindowDemo.java
License:Apache License
private InfoWindowContent displayInfoWindowMaxWidget() { final InfoWindowContent content = new InfoWindowContent("There's more to see (hit the maximize button)"); content.setMaxTitle(new HTML("<i>Maximized Italic Boots</i>")); VerticalPanel panel = new VerticalPanel(); panel.add(new Image("boot.jpg")); Button b = new Button("Click for Message"); final Label l = new Label(); HorizontalPanel hp = new HorizontalPanel(); hp.add(b);/* w w w. jav a 2 s . c o m*/ hp.add(l); l.getElement().getStyle().setPropertyPx("margin", 7); b.addClickListener(new ClickListener() { public void onClick(Widget w) { GWT.log("Got click in maximized window.", null); if (l.getText().equals("")) { l.setText("Hello World!"); } else { l.setText(""); } } }); panel.add(hp); panel.setSpacing(10); content.setMaxContent(panel); return content; }
From source file:com.google.gwt.maps.sample.hellomaps.client.StreetviewOverlayDemo.java
License:Apache License
public StreetviewOverlayDemo() { Panel panel = new FlowPanel(); map = new MapWidget(LatLng.newInstance(40.652513, -73.936615), 12); map.setSize("640px", "480px"); panel.add(map);//from www .ja v a 2s.c om Button toggleStreetview = new Button("Toggle Street View Overlay"); toggleStreetview.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (svShown) { map.removeOverlay(svOverlay); } else { map.addOverlay(svOverlay); } svShown = !svShown; } }); panel.add(toggleStreetview); final Label changeLabel = new Label(); panel.add(changeLabel); initWidget(panel); svOverlay = new StreetviewOverlay(); svOverlay.addStreetviewOverlayChangedHandler(new StreetviewOverlayChangedHandler() { public void onChanged(StreetviewOverlayChangedEvent event) { changeLabel.setText("Last Changed: " + new Date()); } }); }
From source file:com.google.gwt.maps.sample.hellomaps.client.TrafficOverlayDemo.java
License:Apache License
public TrafficOverlayDemo() { Panel panel = new FlowPanel(); map = new MapWidget(LatLng.newInstance(40.652513, -73.936615), 12); map.setSize("640px", "480px"); panel.add(map);/*from w ww . ja v a 2 s .c om*/ Button toggleTraffic = new Button("Toggle Traffic"); toggleTraffic.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (trafficShown) { map.removeOverlay(trafficInfo); } else { map.addOverlay(trafficInfo); } trafficShown = !trafficShown; } }); panel.add(toggleTraffic); final Label changeLabel = new Label(); panel.add(changeLabel); initWidget(panel); trafficInfo = new TrafficOverlay(); trafficInfo.addTrafficOverlayChangedHandler(new TrafficOverlayChangedHandler() { public void onChanged(TrafficOverlayChangedEvent event) { changeLabel.setText("Last Changed: " + new Date()); } }); }
From source file:com.google.gwt.modernizr.client.csssample.CssSample.java
private void addLabel(String featureName, boolean isSupported, String cssClassName) { Label l = new Label(); if (isSupported) { l.setText("Your browser support " + featureName + " feature"); } else {// w w w . j a va 2 s . c o m l.setText("Your browser doesn't support " + featureName + " feature"); } l.addStyleName(cssClassName); RootPanel.get().add(l); }
From source file:com.google.gwt.sample.client.mystockwatcherEntryPoint.java
/** * Update a single row in the stock table. * * @param price Stock data for a single row. *///from w w w . j a va2 s .c o m private void updateTable(StockData price) { // Make sure the stock is still in the stock table. if (!stocks.contains(price.getSymbol())) { return; } int row = stocks.indexOf(price.getSymbol()) + 1; // Format the data in the Price and Change fields. String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice()); NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00"); String changeText = changeFormat.format(price.getChange()); String changePercentText = changeFormat.format(price.getChangePercent()); // Populate the Price and Change fields with new data. stocksFlexTable.setText(row, 1, priceText); Label changeWidget = (Label) stocksFlexTable.getWidget(row, 2); changeWidget.setText(changeText + " (" + changePercentText + "%)"); // Change the color of text in the Change field based on its value. String changeStyleName = "noChange"; if (price.getChangePercent() < -0.1f) { changeStyleName = "negativeChange"; } else if (price.getChangePercent() > 0.1f) { changeStyleName = "positiveChange"; } changeWidget.setStyleName(changeStyleName); }
From source file:com.google.gwt.sample.client.stockwatcher.java
private void updateTable(StockPrice price) { int row;// ww w . j a v a 2 s .co m String priceText, diffText, diffPercentText; NumberFormat diffFormat; Label changeWidget; String changeStyleName = "noChange"; if (stocks.contains(price.getName()) == false) { return; } //Format text row = stocks.indexOf(price.getName()) + 1; priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice()); diffFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00"); diffText = diffFormat.format(price.getDiff()); diffPercentText = diffFormat.format(price.getDiffPercent()); //Populate price stocksTable.setText(row, 1, priceText); changeWidget = (Label) stocksTable.getWidget(row, 2); changeWidget.setText(diffText + " (" + diffPercentText + "%)"); // Change the color of text in the Change field based on its value. if (price.getDiffPercent() < -0.1f) { changeStyleName = "negativeChange"; } else if (price.getDiffPercent() > 0.1f) { changeStyleName = "positiveChange"; } changeWidget.setStyleName(changeStyleName); }
From source file:com.google.gwt.sample.SE_group9.client.Menu.java
public Panel createAccordionPanel() { Panel accordionPanel = new Panel(); accordionPanel.setTitle("Filter Selection"); accordionPanel.setHeight(400);//from w ww .j a va 2 s.c o m accordionPanel.setLayout(new AccordionLayout(true)); /********PANEL Search ********************************************************************************************/ Panel panelsix = new Panel("SearchBox", "<p>Panel5 content!</p>"); panelsix.setIconCls("user-add-icon"); FormPanel searchPanels = createSearchs(); panelsix.add(searchPanels); accordionPanel.add(panelsix); /********PANEL ONE ********************************************************************************************/ Panel panelOne = new Panel("Year", "<p>Panel1 content!</p>"); panelOne.setIconCls("settings-icon"); final ListBox yearpanel = createYearList(); panelOne.add(yearpanel); panelOne.add(btestyear); final Button btestshow = new Button("Show Year"); panelOne.add(btestshow); final Label ltestyear = new Label(); panelOne.add(ltestyear); yearpanel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { int numberindex = yearpanel.getSelectedIndex(); clickedStringyear = yearpanel.getItemText(numberindex); filterConditionArray[0] = clickedStringyear; btestyear.setText(clickedStringyear); btestyear.setText("" + filteredMoviesArrays.length); ltestyear.setText("Button: " + clickedStringyear); } }); accordionPanel.add(panelOne); /********PANEL TWO ********************************************************************************************/ Panel panelTwo = new Panel("Language", "<p>Panel2 content!</p>"); final ListBox languepanel = createLanguages(); panelTwo.setIconCls("folder-icon"); panelTwo.add(languepanel); languepanel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { int numberindex = languepanel.getSelectedIndex(); clickedStringlanguage = languepanel.getItemText(numberindex); filterConditionArray[1] = clickedStringlanguage; } }); accordionPanel.add(panelTwo); /********PANEL THREE ********************************************************************************************/ Panel panelThree = new Panel("Genre", "<p>Panel3 content!</p>"); final ListBox genrepanel = createGenreList(); panelThree.setIconCls("user-add-icon"); panelThree.add(genrepanel); genrepanel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { int numberindex = genrepanel.getSelectedIndex(); clickedStringgenre = genrepanel.getItemText(numberindex); filterConditionArray[2] = clickedStringgenre; } }); accordionPanel.add(panelThree); /********PANEL FOUR ********************************************************************************************/ Panel panelFour = new Panel("Lenght", "<p>Panel4 content!</p>"); panelFour.setIconCls("user-add-icon"); panelFour.add(createLength()); accordionPanel.add(panelFour); /********PANEL FIVE ********************************************************************************************/ Panel panelFive = new Panel("Country", "<p>Panel5 content!</p>"); panelFive.setIconCls("user-add-icon"); FormPanel statespanel = createStates(); panelFive.add(statespanel); accordionPanel.add(panelFive); return accordionPanel; }
From source file:com.google.gwt.sample.SE_group9.client.Menu.java
public FormPanel createStates() { FormPanel form = new FormPanel(); form.setLabelWidth(35);// w w w .j a va2 s . co m form.setBorder(false); //create a Store using local array data final Store store = new SimpleStore(new String[] { "abbr", "state", }, getStates()); store.load(); final ComboBox cb = new ComboBox(); cb.setForceSelection(true); cb.setMinChars(1); cb.setFieldLabel("Country"); cb.setStore(store); cb.setDisplayField("state"); cb.setMode(ComboBox.LOCAL); cb.setTriggerAction(ComboBox.ALL); cb.setEmptyText("Enter country"); cb.setLoadingText("Searching..."); cb.setTypeAhead(true); cb.setSelectOnFocus(true); cb.setWidth(180); cb.setHideTrigger(false); cb.addListener(new ComboBoxListenerAdapter() { public boolean doBeforeQuery(ComboBox comboBox, ComboBoxCallback cb) { System.out.println("ComboBox::doBeforeQuery()"); return true; } public boolean doBeforeSelect(ComboBox comboBox, Record record, int index) { System.out.println("ComboBox::doBeforeSelect(" + record.getAsString("state") + ")"); return super.doBeforeSelect(comboBox, record, index); } public void onCollapse(ComboBox comboBox) { System.out.println("ComboBox::onCollapse()"); } public void onExpand(ComboBox comboBox) { System.out.println("ComboBox::onExpand()"); } public void onSelect(ComboBox comboBox, Record record, int index) { System.out.println("ComboBox::onSelect('" + record.getAsString("state") + "')"); clickedStringcountry = record.getAsString("state"); } public void onBlur(Field field) { System.out.println("ComboBox::onBlur()"); } public void onChange(Field field, Object newVal, Object oldVal) { System.out.println("ComboBox::onChange(" + oldVal + "-->" + newVal + ")"); } public void onFocus(Field field) { System.out.println("ComboBox::onFocus()"); } public void onInvalid(Field field, String msg) { super.onInvalid(field, msg); } public void onSpecialKey(Field field, EventObject e) { System.out.println("ComboBox::onSpecialKey(key code " + e.getKey() + ")"); } }); final Label muti = new Label(); form.add(muti); form.add(bSHow); bSHow.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { filterConditionArray[4] = cb.getText(); muti.setText("Country: " + cb.getText()); } }); form.add(cb); return form; }
From source file:com.google.gwt.sample.SE_group9.client.Menu.java
public FormPanel createSearchs() { FormPanel form = new FormPanel(); form.setLabelWidth(35);/*from w w w. j av a 2 s. com*/ form.setBorder(false); final ComboBox searchMovie = new ComboBox(); searchMovie.setWidth(120); searchMovie.setHideTrigger(false); searchMovie.setEmptyText("Movie Name"); searchMovie.setFieldLabel("1. "); form.add(searchMovie); final ComboBox searchLang = new ComboBox(); searchLang.setWidth(120); searchLang.setEmptyText("Language"); searchMovie.setFieldLabel("2. "); form.add(searchLang); final ComboBox searchYear = new ComboBox(); searchYear.setWidth(120); searchYear.setEmptyText("Year"); searchMovie.setFieldLabel("3. "); form.add(searchYear); final ComboBox searchCountry = new ComboBox(); searchCountry.setWidth(120); searchCountry.setEmptyText("Country"); searchMovie.setFieldLabel("4. "); form.add(searchCountry); final ComboBox searchGenre = new ComboBox(); searchGenre.setWidth(120); searchGenre.setEmptyText("Genre"); searchMovie.setFieldLabel("5. "); form.add(searchGenre); final ComboBox searchlength = new ComboBox(); searchlength.setWidth(120); searchlength.setEmptyText("Movielength"); searchMovie.setFieldLabel("6. "); form.add(searchlength); final Label muti = new Label(); form.add(muti); bresetSearchFilter.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { searchMovie.clearValue(); searchLang.clearValue(); searchYear.clearValue(); searchCountry.clearValue(); searchGenre.clearValue(); searchlength.clearValue(); filterConditionArray[0] = ""; filterConditionArray[1] = ""; filterConditionArray[2] = ""; filterConditionArray[3] = ""; filterConditionArray[4] = ""; filterConditionArray[5] = ""; muti.setText(searchMovie.getText() + ", " + searchLang.getText() + ", " + searchGenre.getText() + ", " + searchlength.getText() + ", " + searchCountry.getText()); } }); baddtoFilter.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { filterConditionArray[0] = searchYear.getText(); filterConditionArray[1] = searchLang.getText(); filterConditionArray[2] = searchGenre.getText(); filterConditionArray[3] = searchlength.getText(); filterConditionArray[4] = searchCountry.getText(); filterConditionArray[5] = searchMovie.getText(); muti.setText(searchMovie.getText() + ", " + searchLang.getText() + ", " + searchGenre.getText() + ", " + searchlength.getText() + ", " + searchCountry.getText()); } }); form.add(baddtoFilter); form.add(bresetSearchFilter); return form; }
From source file:com.google.gwt.sample.showcase.client.content.text.CwBasicText.java
License:Apache License
/** * Update the text in one of the selection labels. * * @param textBox the text box/*from ww w . j a v a2 s . c o m*/ * @param label the label to update */ @ShowcaseSource private void updateSelectionLabel(TextBoxBase textBox, Label label) { label.setText(constants.cwBasicTextSelected() + ": " + textBox.getCursorPos() + ", " + textBox.getSelectionLength()); }