本文整理汇总了Java中com.google.gwt.dom.client.SelectElement.add方法的典型用法代码示例。如果您正苦于以下问题:Java SelectElement.add方法的具体用法?Java SelectElement.add怎么用?Java SelectElement.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.dom.client.SelectElement
的用法示例。
在下文中一共展示了SelectElement.add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertItem
import com.google.gwt.dom.client.SelectElement; //导入方法依赖的package包/类
/**
* Inserts an item into the list box, specifying its direction and an initial value for the item. If the index is less than zero, or greater than or equal
* to the length of the list, then the item will be appended to the end of the list.
*
* @param item the text of the item to be inserted
* @param dir the item's direction. If {@code null}, the item is displayed in the widget's overall direction, or, if a direction estimator has been set, in
* the item's estimated direction.
* @param value the item's value, to be submitted if it is part of a {@link FormPanel}.
* @param index the index at which to insert it
*/
public void insertItem(String item, Direction dir, String value, int index) {
SelectElement select = getSelectElement();
OptionElement option = Document.get().createOptionElement();
setOptionText(option, item, dir);
option.setValue(value);
int itemCount = select.getLength();
if (index < 0 || index > itemCount) {
index = itemCount;
}
if (index == itemCount) {
select.add(option, null);
} else {
OptionElement before = select.getOptions().getItem(index);
select.add(option, before);
}
}
示例2: insertItem
import com.google.gwt.dom.client.SelectElement; //导入方法依赖的package包/类
@Override
public void insertItem(String item, Direction dir, String value, int index) {
SelectElement select = getElement().cast();
OptionElement option = Document.get().createOptionElement();
setOptionText(option, item, dir);
option.setValue(value);
option.setTitle(item);
int itemCount = select.getLength();
if (index < 0 || index > itemCount) {
index = itemCount;
}
if (index == itemCount) {
select.add(option, null);
} else {
OptionElement before = select.getOptions().getItem(index);
select.add(option, before);
}
}
示例3: createChildOption
import com.google.gwt.dom.client.SelectElement; //导入方法依赖的package包/类
private OptionElement createChildOption(Document document, SelectElement select, String value, String label) {
OptionElement option = document.createOptionElement();
option.setValue(value);
option.setInnerText(label);
select.add(option, null);
return option;
}
示例4: setupLocaleSelect
import com.google.gwt.dom.client.SelectElement; //导入方法依赖的package包/类
private void setupLocaleSelect() {
final SelectElement select = (SelectElement) Document.get().getElementById(LANG_ELEMENT_ID);
String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
String[] localeNames = LocaleInfo.getAvailableLocaleNames();
for (String locale : localeNames) {
if (!DEFAULT_LOCALE.equals(locale)) {
String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
OptionElement option = Document.get().createOptionElement();
option.setValue(locale);
option.setText(displayName);
select.add(option, null);
if (locale.equals(currentLocale)) {
select.setSelectedIndex(select.getLength() - 1);
}
}
}
EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {
@Override
public boolean onChange(ChangeEvent event, Element context) {
UrlBuilder builder = Location.createUrlBuilder().setParameter(
LOCALE_URLBUILDER_PARAMETER, select.getValue());
Window.Location.replace(builder.buildString());
localeService.storeLocale(select.getValue());
return true;
}
});
}
示例5: addItemWithStyle
import com.google.gwt.dom.client.SelectElement; //导入方法依赖的package包/类
public void addItemWithStyle(String item, String value) {
final SelectElement select = getElement().cast();
final OptionElement option = Document.get().createOptionElement();
option.setText(item);
option.setValue(value);
option.setClassName(styleName);
select.add(option, null);
}
示例6: setupLocaleSelect
import com.google.gwt.dom.client.SelectElement; //导入方法依赖的package包/类
private void setupLocaleSelect() {
final SelectElement select = (SelectElement) Document.get().getElementById("lang");
String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
String[] localeNames = LocaleInfo.getAvailableLocaleNames();
for (String locale : localeNames) {
if (!DEFAULT_LOCALE.equals(locale)) {
String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
OptionElement option = Document.get().createOptionElement();
option.setValue(locale);
option.setText(displayName);
select.add(option, null);
if (locale.equals(currentLocale)) {
select.setSelectedIndex(select.getLength() - 1);
}
}
}
EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {
@Override
public boolean onChange(ChangeEvent event, Element context) {
UrlBuilder builder = Location.createUrlBuilder().setParameter(
"locale", select.getValue());
Window.Location.replace(builder.buildString());
localeService.storeLocale(select.getValue());
return true;
}
});
}