本文整理汇总了Java中java.awt.im.spi.InputMethodDescriptor.hasDynamicLocaleList方法的典型用法代码示例。如果您正苦于以下问题:Java InputMethodDescriptor.hasDynamicLocaleList方法的具体用法?Java InputMethodDescriptor.hasDynamicLocaleList怎么用?Java InputMethodDescriptor.hasDynamicLocaleList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.im.spi.InputMethodDescriptor
的用法示例。
在下文中一共展示了InputMethodDescriptor.hasDynamicLocaleList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import java.awt.im.spi.InputMethodDescriptor; //导入方法依赖的package包/类
private void show(Component origin, InputMethodContext imc) {
imContext = imc;
for (int i = 0; i < getItemCount(); i++) {
MenuItem item = getItem(i);
if (!(item instanceof IMSubmenu)) {
// skip all non-menu elements, such as separators
continue;
}
IMSubmenu subMenu = (IMSubmenu) item;
InputMethodDescriptor desc = subMenu.getDesc();
if (desc == null) {
continue;
}
if (desc.hasDynamicLocaleList()) {
subMenu.removeAll();
subMenu.addLocales();
}
subMenu.checkItems();
i++;
}
show(origin, 50, 50);
}
示例2: addOneInputMethodToMenu
import java.awt.im.spi.InputMethodDescriptor; //导入方法依赖的package包/类
void addOneInputMethodToMenu(InputMethodLocator locator, String currentSelection) {
InputMethodDescriptor descriptor = locator.getDescriptor();
String label = descriptor.getInputMethodDisplayName(null, Locale.getDefault());
String command = locator.getActionCommandString();
Locale[] locales = null;
int localeCount;
try {
locales = descriptor.getAvailableLocales();
localeCount = locales.length;
} catch (AWTException e) {
// ??? should have better error handling -
// tell user what happened, then remove this input method from the list.
// For the time being, just show it disabled.
localeCount = 0;
}
if (localeCount == 0) {
// could be IIIMP adapter which has lost its connection
addMenuItem(label, null, currentSelection);
} else if (localeCount == 1) {
if (descriptor.hasDynamicLocaleList()) {
// try to make sure that what the user sees and what
// we eventually select is consistent even if the locale
// list changes in the meantime
label = descriptor.getInputMethodDisplayName(locales[0], Locale.getDefault());
command = locator.deriveLocator(locales[0]).getActionCommandString();
}
addMenuItem(label, command, currentSelection);
} else {
Object submenu = createSubmenu(label);
add(submenu);
for (int j = 0; j < localeCount; j++) {
Locale locale = locales[j];
String subLabel = getLocaleName(locale);
String subCommand = locator.deriveLocator(locale).getActionCommandString();
addMenuItem(submenu, subLabel, subCommand, currentSelection);
}
}
}