当前位置: 首页>>代码示例>>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;未经允许,请勿转载。