當前位置: 首頁>>代碼示例>>Java>>正文


Java ListBox.setSelectedIndex方法代碼示例

本文整理匯總了Java中com.google.gwt.user.client.ui.ListBox.setSelectedIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java ListBox.setSelectedIndex方法的具體用法?Java ListBox.setSelectedIndex怎麽用?Java ListBox.setSelectedIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.user.client.ui.ListBox的用法示例。


在下文中一共展示了ListBox.setSelectedIndex方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadAndSetDayHour

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
public void loadAndSetDayHour(ListBox day_list, HourListBox hour_list, ListBox minute_list, int year, int month, int day, int hour, int min) {
	// Load the valid days for this month (which as set above) and year.
	days(day_list, year, month);

	if ( day < Integer.valueOf(day_list.getValue(0)).intValue() ) {
		day_list.setSelectedIndex(0);
	} else if ( day > Integer.valueOf(day_list.getValue(day_list.getItemCount() - 1)).intValue() ) {
		day_list.setSelectedIndex(day_list.getItemCount() - 1);
	} else {

		for (int i = 0; i < day_list.getItemCount(); i++) {
			String v = day_list.getValue(i);
			if ( v.equals(GeoUtil.format_two(day)) ) {
				day_list.setSelectedIndex(i);
			}
		}
	}
	
	loadAndSetHour(hour_list, minute_list, year, month, Integer.valueOf(day_list.getValue(day_list.getSelectedIndex())).intValue(), hour, min);
	
}
 
開發者ID:NOAA-PMEL,項目名稱:LAS,代碼行數:22,代碼來源:DateTimeWidget.java

示例2: moveAllItems

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
private Set<String> moveAllItems(ListBox source, ListBox target) {
    final Set<String> movedItems = new HashSet<String>();
    int size = source.getItemCount();
    for (int i = 0; i < size; i++) {
        movedItems.add(source.getValue(i));
        final String text = source.getItemText(i);
        final String value = source.getValue(i);
        target.addItem(text, value);
        target.setItemSelected(target.getItemCount() - 1, true);
    }
    target.setFocus(true);
    if (source.getItemCount() > 0) {
        target.setSelectedIndex(0);
    }
    source.clear();
    return movedItems;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:18,代碼來源:CubaTwinColSelectWidget.java

示例3: setValueOfDocFieldWidget

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
private void setValueOfDocFieldWidget(String name, String value) {
	for (EditableWidgetStorage editableWidgetStorage : docFieldWidgets) {
		if (editableWidgetStorage.getData().getName().equals(name)) {
			if (editableWidgetStorage.isListBox) {
				ListBox listBoxwidget = editableWidgetStorage.getListBoxwidget();
				if (listBoxwidget != null) {
					for (int i = 0; i < listBoxwidget.getItemCount(); i++) {
						String listBoxValue = listBoxwidget.getValue(i);
						if (listBoxValue.equals(value)) {
							listBoxwidget.setSelectedIndex(i);
							break;
						}
					}
				}
			} else {
				ValidatableWidget<TextBox> textBoxWidget = editableWidgetStorage.getTextBoxWidget();
				if (textBoxWidget != null) {
					textBoxWidget.getWidget().setValue(value);
				}
			}
			break;
		}
	}
}
 
開發者ID:kuzavas,項目名稱:ephesoft,代碼行數:25,代碼來源:EditBoxExporterView.java

示例4: setFieldValue

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
protected void setFieldValue(ListBox field, String value) {
	try {
		for (int i = 0; i < field.getItemCount(); i++) {
			String v = field.getValue(i);

			if (v.equals(value)) {
				field.setSelectedIndex(i);
				return;
			}
		}

		field.setSelectedIndex(0);

	} catch (Exception e) {
		field.setSelectedIndex(0);
	}
}
 
開發者ID:dawg6,項目名稱:dhcalc,代碼行數:18,代碼來源:BasePanel.java

示例5: checkDuplicate

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
protected void checkDuplicate(ListBox lb) {
	int selected = lb.getSelectedIndex();
	
	boolean prev = disableListeners;
	disableListeners = true;

	for (int i = 0; i < NUM_PASSIVES; i++) {
		ListBox l = listBoxes.get(i);
		
		if ((l != lb) && (l.getSelectedIndex() == selected)) {
			l.setSelectedIndex(0);
			setTooltip(anchors.get(i), null);
		}
	}

	disableListeners = prev;
}
 
開發者ID:dawg6,項目名稱:dhcalc,代碼行數:18,代碼來源:PassivesPanel.java

示例6: selectSkill

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
private void selectSkill(ListBox list, ActiveSkill skill) {

		for (int i = 0; i < list.getItemCount(); i++) {
			String value = list.getValue(i);

			if (skill != null) {
				if (value.equals(skill.name())) {
					list.setSelectedIndex(i);
					return;
				}
			} else {
				if ((value == null) || (value.trim().length() == 0)) {
					list.setSelectedIndex(i);
					return;
				}
			}

		}

		list.setSelectedIndex(0);
	}
 
開發者ID:dawg6,項目名稱:dhcalc,代碼行數:22,代碼來源:StatsPanel.java

示例7: checkDuplicate

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
private void checkDuplicate(ListBox lb) {
	int selected = lb.getSelectedIndex();

	boolean prev = disableListeners;
	disableListeners = true;

	for (int i = 0; i < NUM_SKILLS; i++) {
		ListBox l = skillBoxes.get(i);

		if ((l != lb) && (l.getSelectedIndex() == selected)) {
			l.setSelectedIndex(0);
			setRunes(runeAnchors.get(i), runeBoxes.get(i), null);
			setSkillAnchor(skillAnchors.get(i), null);
		}
	}

	disableListeners = prev;
}
 
開發者ID:dawg6,項目名稱:dhcalc,代碼行數:19,代碼來源:SkillsPanel.java

示例8: setRunes

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
private void setRunes(Anchor anchor2, ListBox list2, ActiveSkill skill) {

		list2.clear();


		if (skill != null) {
			for (Rune r : skill.getRunes()) {
				list2.addItem(r.getLongName(), r.name());
			}
		} else {
			list2.addItem("None", Rune.None.name());
		}

		list2.setSelectedIndex(0);
		setRuneAnchor(skill, anchor2, Rune.None);
	}
 
開發者ID:dawg6,項目名稱:dhcalc,代碼行數:17,代碼來源:SkillsPanel.java

示例9: selectRune

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
private void selectRune(ActiveSkill skill, Anchor anchor2, ListBox list2,
		Rune rune) {

	if (rune == null) {
		list2.setSelectedIndex(0);
	} else {
		int n = list2.getItemCount();

		for (int i = 0; i < n; i++) {
			String value = list2.getValue(i);

			if (value.equals(rune.name())) {
				list2.setSelectedIndex(i);
				break;
			}
		}
	}

	this.setRuneAnchor(skill, anchor2, rune);
}
 
開發者ID:dawg6,項目名稱:dhcalc,代碼行數:21,代碼來源:SkillsPanel.java

示例10: selectSkill

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
private void selectSkill(Anchor anchor, ListBox list, ActiveSkill skill,
		Anchor anchor2, ListBox list2) {

	if (skill == null) {
		list.setSelectedIndex(0);
	} else {
		int n = list.getItemCount();

		for (int i = 0; i < n; i++) {
			String value = list.getValue(i);

			if (value.equals(skill.name())) {
				list.setSelectedIndex(i);
				break;
			}
		}
	}

	this.setSkillAnchor(anchor, skill);
	this.setRunes(anchor2, list2, skill);
}
 
開發者ID:dawg6,項目名稱:dhcalc,代碼行數:22,代碼來源:SkillsPanel.java

示例11: select

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
private void select(ListBox l, String value) {
	for (int i = 0; i < l.getItemCount(); i++) {
		if (l.getValue(i).equals(value)) {
			l.setSelectedIndex(i);
			return;
		}
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:9,代碼來源:ReservationEdit.java

示例12: makeTemplatesMenu

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
/**
 * Creates a drop down menu for selecting Template repositories.
 * @return the drop down menu of repository Urls.
 */
private ListBox makeTemplatesMenu() {
  final ListBox templatesMenu = new ListBox();
  templatesMenu.addItem(MESSAGES.templateUploadNewUrlCaption());
  templatesMenu.addItem(MIT_TEMPLATES);

  for (int k = 0; k < dynamicTemplateUrls.size(); k++) { // Dynamically added Urls
    templatesMenu.addItem(dynamicTemplateUrls.get(k));
  }
  templatesMenu.setSelectedIndex(MIT_TEMPLATES_INDEX);
  templatesMenu.addChangeHandler(new ChangeHandler() {
      public void onChange(ChangeEvent event) {
        int selectedIndex = templatesMenu.getSelectedIndex();

        if (selectedIndex == 0) {
          templatesMenu.setSelectedIndex(lastSelectedIndex);
          usingExternalTemplate = true; // MIT templates at index 1
          removeButton.setVisible(false);
          new InputTemplateUrlWizard(instance).center();     // This will do a callback
        } else if (selectedIndex == 1) {
          removeButton.setVisible(false);          lastSelectedIndex = selectedIndex;
          usingExternalTemplate = false; // MIT templates at index 1
          templateHostUrl = "";
          retrieveSelectedTemplates(templatesMenu.getValue(selectedIndex));  // may do callback
        } else {
          removeButton.setVisible(true);         lastSelectedIndex = selectedIndex;
          usingExternalTemplate = true; // MIT templates at index 1
          templateHostUrl = templatesMenu.getValue(selectedIndex);
          retrieveSelectedTemplates(templatesMenu.getValue(selectedIndex));  // may do callback
        }
      }
    });
  templatesMenu.setVisibleItemCount(1);  // Turns menu into a drop-down list).
  return templatesMenu;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:39,代碼來源:TemplateUploadWizard.java

示例13: loadAndSetMonthDayHour

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
private void loadAndSetMonthDayHour(ListBox month_list, ListBox day_list, HourListBox hour_list, ListBox minute_list, int year, int month, int day, int hour, int min) {
	// Load the valid months for this year.
	months(month_list, year);

	int low_month_number = monthToInt(month_list.getValue(0));
	int hi_month_number = monthToInt(month_list.getValue(month_list.getItemCount() - 1));
	
	DateTime requested_instance = new DateTime(year, month, day, hour, min, chrono).withZone(DateTimeZone.UTC);
	String month_name = monthFormat.print(requested_instance.getMillis());

	if ( month < low_month_number ) {
		// If the current month is before the first month in the list
		// set to the first month.
		month_list.setSelectedIndex(0);
	} else if ( month > hi_month_number) {
		// If the current month is after the last month in the list
		// set to the last month.
		month_list.setSelectedIndex(month_list.getItemCount() - 1);
	} else {
		// Else set to that month
		for (int i = 0; i < month_list.getItemCount(); i++) {
			String v = month_list.getValue(i);
			if ( v.equals(month_name) ) {
				month_list.setSelectedIndex(i);
			}
		}
	}

	
	int selected_month = monthToInt(month_list.getValue(month_list.getSelectedIndex()));
	loadAndSetDayHour(day_list, hour_list, minute_list, year, selected_month, day, hour, min);	
}
 
開發者ID:NOAA-PMEL,項目名稱:LAS,代碼行數:33,代碼來源:DateTimeWidget.java

示例14: onModuleLoad

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
public void onModuleLoad() {
    PublishSubject<String> query = PublishSubject.create();

    TextBox text = new TextBox(); RootPanel.get().add(text);
    text.addValueChangeHandler(e -> query.onNext(e.getValue()));

    Button search = new Button("search"); RootPanel.get().add(search);
    search.addClickHandler(e -> query.onNext(text.getValue()));

    ListBox url = new ListBox(); RootPanel.get().add(url);
    url.addItem(NOMINATIM_OPENSTREETMAP);
    url.addItem("http://localhost:8080/");
    url.addChangeHandler(e -> query.onNext(text.getValue()));

    FlowPanel results = new FlowPanel(); RootPanel.get().add(results);

    // remember last selected server
    Storage storage = Storage.getLocalStorageIfSupported();
    if (storage != null) {
        try {
            url.setSelectedIndex(Integer.valueOf(storage.getItem("nominatim.url")));
        } catch (Exception ignore) {}
        url.addChangeHandler(c -> storage.setItem("nominatim.url", Integer.toString(url.getSelectedIndex())));
    }

    // on each tick, re-configure root resource and fire new request
    query.switchMap(q -> {
        results.clear();
        if (q == null || q.isEmpty()) return Observable.empty();
        Nominatim nominatim = new Nominatim_RestServiceModel(() -> osm(url.getSelectedItemText()));
        return nominatim.search(q, "json").doOnNext(n -> results.add(new Label(
                "[" + (int) (n.importance * 10.) + "] " + n.display_name + " (" + n.lon + "," + n.lat + ")")));
    }).retry((cnt, err) -> {
        GWT.log("request error: " + err, err); return true;
    }).subscribe();

     // fires initial search
    text.setValue("Málaga,España", true);
}
 
開發者ID:ibaca,項目名稱:autorest-nominatim-example,代碼行數:40,代碼來源:ExampleEntryPoint.java

示例15: setListBoxStyleName

import com.google.gwt.user.client.ui.ListBox; //導入方法依賴的package包/類
/**
 * Allows to set the style name as selected in the list box
 * @param listBox the list box to set the value in
 * @param styleName the style which we want to set as selected
 */
public void setListBoxStyleName( final ListBox listBox, final String styleName ) {
	//First set the selected element
	for( int index = 0; index < listBox.getItemCount(); index++ ) {
		if( listBox.getValue( index ).equals( styleName ) ) {
			listBox.setSelectedIndex( index );
			break;
		}
	}
	//Second, update the sample view
	updateSampleViewStyles();
}
 
開發者ID:ivan-zapreev,項目名稱:x-cure-chat,代碼行數:17,代碼來源:FontSelectorPanelUI.java


注:本文中的com.google.gwt.user.client.ui.ListBox.setSelectedIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。