下面列出了怎么用java.awt.im.spi.InputMethod的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* @see java.awt.im.spi.InputMethodContext#enableClientWindowNotification
*/
synchronized void enableClientWindowNotification(InputMethod requester,
boolean enable) {
// in case this request is not from the current input method,
// store the request and handle it when this requesting input
// method becomes the current one.
if (requester != inputMethod) {
if (perInputMethodState == null) {
perInputMethodState = new HashMap<>(5);
}
perInputMethodState.put(requester, Boolean.valueOf(enable));
return;
}
if (clientWindowNotificationEnabled != enable) {
clientWindowLocation = null;
clientWindowNotificationEnabled = enable;
}
if (clientWindowNotificationEnabled) {
if (!addedClientWindowListeners()) {
addClientWindowListeners();
}
if (clientWindowListened != null) {
clientWindowLocation = null;
notifyClientWindowChange(clientWindowListened);
}
} else {
if (addedClientWindowListeners()) {
removeClientWindowListeners();
}
}
}
/**
* @see java.awt.im.InputContext#isCompositionEnabled
* @exception UnsupportedOperationException when input method is null
*/
public boolean isCompositionEnabled() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
return inputMethod.isCompositionEnabled();
}
/**
* @return a string with information about the current input method.
* @exception UnsupportedOperationException when input method is null
*/
public String getInputMethodInfo() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException("Null input method");
}
String inputMethodInfo = null;
if (inputMethod instanceof InputMethodAdapter) {
// returns the information about the host native input method.
inputMethodInfo = ((InputMethodAdapter)inputMethod).
getNativeInputMethodInfo();
}
// extracts the information from the InputMethodDescriptor
// associated with the current java input method.
if (inputMethodInfo == null && inputMethodLocator != null) {
inputMethodInfo = inputMethodLocator.getDescriptor().
getInputMethodDisplayName(getLocale(), SunToolkit.
getStartupLocale());
}
if (inputMethodInfo != null && !inputMethodInfo.equals("")) {
return inputMethodInfo;
}
// do our best to return something useful.
return inputMethod.toString() + "-" + inputMethod.getLocale().toString();
}
/**
* @see java.awt.im.InputContext#getInputMethodControlObject
*/
public synchronized Object getInputMethodControlObject() {
InputMethod inputMethod = getInputMethod();
if (inputMethod != null) {
return inputMethod.getControlObject();
} else {
return null;
}
}
/**
* @see java.awt.im.InputContext#isCompositionEnabled
* @exception UnsupportedOperationException when input method is null
*/
public boolean isCompositionEnabled() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
return inputMethod.isCompositionEnabled();
}
/**
* @see java.awt.im.spi.InputMethodContext#enableClientWindowNotification
*/
synchronized void enableClientWindowNotification(InputMethod requester,
boolean enable) {
// in case this request is not from the current input method,
// store the request and handle it when this requesting input
// method becomes the current one.
if (requester != inputMethod) {
if (perInputMethodState == null) {
perInputMethodState = new HashMap<>(5);
}
perInputMethodState.put(requester, Boolean.valueOf(enable));
return;
}
if (clientWindowNotificationEnabled != enable) {
clientWindowLocation = null;
clientWindowNotificationEnabled = enable;
}
if (clientWindowNotificationEnabled) {
if (!addedClientWindowListeners()) {
addClientWindowListeners();
}
if (clientWindowListened != null) {
clientWindowLocation = null;
notifyClientWindowChange(clientWindowListened);
}
} else {
if (addedClientWindowListeners()) {
removeClientWindowListeners();
}
}
}
private synchronized InputMethod getInputMethod() {
if (inputMethod != null) {
return inputMethod;
}
if (inputMethodCreationFailed) {
return null;
}
inputMethod = getInputMethodInstance();
return inputMethod;
}
/**
* @see java.awt.im.InputContext#isCompositionEnabled
* @exception UnsupportedOperationException when input method is null
*/
public boolean isCompositionEnabled() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
return inputMethod.isCompositionEnabled();
}
private synchronized InputMethod getInputMethod() {
if (inputMethod != null) {
return inputMethod;
}
if (inputMethodCreationFailed) {
return null;
}
inputMethod = getInputMethodInstance();
return inputMethod;
}
/**
* @see java.awt.im.spi.InputMethodContext#enableClientWindowNotification
*/
synchronized void enableClientWindowNotification(InputMethod requester,
boolean enable) {
// in case this request is not from the current input method,
// store the request and handle it when this requesting input
// method becomes the current one.
if (requester != inputMethod) {
if (perInputMethodState == null) {
perInputMethodState = new HashMap<>(5);
}
perInputMethodState.put(requester, Boolean.valueOf(enable));
return;
}
if (clientWindowNotificationEnabled != enable) {
clientWindowLocation = null;
clientWindowNotificationEnabled = enable;
}
if (clientWindowNotificationEnabled) {
if (!addedClientWindowListeners()) {
addClientWindowListeners();
}
if (clientWindowListened != null) {
clientWindowLocation = null;
notifyClientWindowChange(clientWindowListened);
}
} else {
if (addedClientWindowListeners()) {
removeClientWindowListeners();
}
}
}
private synchronized InputMethod getInputMethod() {
if (inputMethod != null) {
return inputMethod;
}
if (inputMethodCreationFailed) {
return null;
}
inputMethod = getInputMethodInstance();
return inputMethod;
}
/**
* @see java.awt.im.spi.InputMethodContext#enableClientWindowNotification
*/
synchronized void enableClientWindowNotification(InputMethod requester,
boolean enable) {
// in case this request is not from the current input method,
// store the request and handle it when this requesting input
// method becomes the current one.
if (requester != inputMethod) {
if (perInputMethodState == null) {
perInputMethodState = new HashMap<>(5);
}
perInputMethodState.put(requester, Boolean.valueOf(enable));
return;
}
if (clientWindowNotificationEnabled != enable) {
clientWindowLocation = null;
clientWindowNotificationEnabled = enable;
}
if (clientWindowNotificationEnabled) {
if (!addedClientWindowListeners()) {
addClientWindowListeners();
}
if (clientWindowListened != null) {
clientWindowLocation = null;
notifyClientWindowChange(clientWindowListened);
}
} else {
if (addedClientWindowListeners()) {
removeClientWindowListeners();
}
}
}
/**
* @see java.awt.im.InputContext#getInputMethodControlObject
*/
public synchronized Object getInputMethodControlObject() {
InputMethod inputMethod = getInputMethod();
if (inputMethod != null) {
return inputMethod.getControlObject();
} else {
return null;
}
}
/**
* @see java.awt.im.InputContext#reconvert
* @since 1.3
* @exception UnsupportedOperationException when input method is null
*/
public synchronized void reconvert() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
inputMethod.reconvert();
}
/**
* @see java.awt.im.InputContext#isCompositionEnabled
* @exception UnsupportedOperationException when input method is null
*/
public boolean isCompositionEnabled() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
return inputMethod.isCompositionEnabled();
}
/**
* @return a string with information about the current input method.
* @exception UnsupportedOperationException when input method is null
*/
public String getInputMethodInfo() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException("Null input method");
}
String inputMethodInfo = null;
if (inputMethod instanceof InputMethodAdapter) {
// returns the information about the host native input method.
inputMethodInfo = ((InputMethodAdapter)inputMethod).
getNativeInputMethodInfo();
}
// extracts the information from the InputMethodDescriptor
// associated with the current java input method.
if (inputMethodInfo == null && inputMethodLocator != null) {
inputMethodInfo = inputMethodLocator.getDescriptor().
getInputMethodDisplayName(getLocale(), SunToolkit.
getStartupLocale());
}
if (inputMethodInfo != null && !inputMethodInfo.equals("")) {
return inputMethodInfo;
}
// do our best to return something useful.
return inputMethod.toString() + "-" + inputMethod.getLocale().toString();
}
/**
* @see java.awt.im.InputContext#setCompositionEnabled(boolean)
* @exception UnsupportedOperationException when input method is null
*/
public void setCompositionEnabled(boolean enable) {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
inputMethod.setCompositionEnabled(enable);
}
/**
* @see java.awt.im.spi.InputMethodContext#enableClientWindowNotification
*/
synchronized void enableClientWindowNotification(InputMethod requester,
boolean enable) {
// in case this request is not from the current input method,
// store the request and handle it when this requesting input
// method becomes the current one.
if (requester != inputMethod) {
if (perInputMethodState == null) {
perInputMethodState = new HashMap<>(5);
}
perInputMethodState.put(requester, Boolean.valueOf(enable));
return;
}
if (clientWindowNotificationEnabled != enable) {
clientWindowLocation = null;
clientWindowNotificationEnabled = enable;
}
if (clientWindowNotificationEnabled) {
if (!addedClientWindowListeners()) {
addClientWindowListeners();
}
if (clientWindowListened != null) {
clientWindowLocation = null;
notifyClientWindowChange(clientWindowListened);
}
} else {
if (addedClientWindowListeners()) {
removeClientWindowListeners();
}
}
}
/**
* @return a string with information about the current input method.
* @exception UnsupportedOperationException when input method is null
*/
public String getInputMethodInfo() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException("Null input method");
}
String inputMethodInfo = null;
if (inputMethod instanceof InputMethodAdapter) {
// returns the information about the host native input method.
inputMethodInfo = ((InputMethodAdapter)inputMethod).
getNativeInputMethodInfo();
}
// extracts the information from the InputMethodDescriptor
// associated with the current java input method.
if (inputMethodInfo == null && inputMethodLocator != null) {
inputMethodInfo = inputMethodLocator.getDescriptor().
getInputMethodDisplayName(getLocale(), SunToolkit.
getStartupLocale());
}
if (inputMethodInfo != null && !inputMethodInfo.equals("")) {
return inputMethodInfo;
}
// do our best to return something useful.
return inputMethod.toString() + "-" + inputMethod.getLocale().toString();
}
/**
* @see java.awt.im.InputContext#setCompositionEnabled(boolean)
* @exception UnsupportedOperationException when input method is null
*/
public void setCompositionEnabled(boolean enable) {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
inputMethod.setCompositionEnabled(enable);
}
private synchronized InputMethod getInputMethod() {
if (inputMethod != null) {
return inputMethod;
}
if (inputMethodCreationFailed) {
return null;
}
inputMethod = getInputMethodInstance();
return inputMethod;
}
/**
* @see java.awt.im.InputContext#reconvert
* @since 1.3
* @exception UnsupportedOperationException when input method is null
*/
public synchronized void reconvert() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
inputMethod.reconvert();
}
/**
* @see java.awt.im.InputContext#setCompositionEnabled(boolean)
* @exception UnsupportedOperationException when input method is null
*/
public void setCompositionEnabled(boolean enable) {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
inputMethod.setCompositionEnabled(enable);
}
/**
* @see java.awt.im.InputContext#reconvert
* @since 1.3
* @exception UnsupportedOperationException when input method is null
*/
public synchronized void reconvert() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
inputMethod.reconvert();
}
/**
* @return a string with information about the current input method.
* @exception UnsupportedOperationException when input method is null
*/
public String getInputMethodInfo() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException("Null input method");
}
String inputMethodInfo = null;
if (inputMethod instanceof InputMethodAdapter) {
// returns the information about the host native input method.
inputMethodInfo = ((InputMethodAdapter)inputMethod).
getNativeInputMethodInfo();
}
// extracts the information from the InputMethodDescriptor
// associated with the current java input method.
if (inputMethodInfo == null && inputMethodLocator != null) {
inputMethodInfo = inputMethodLocator.getDescriptor().
getInputMethodDisplayName(getLocale(), SunToolkit.
getStartupLocale());
}
if (inputMethodInfo != null && !inputMethodInfo.equals("")) {
return inputMethodInfo;
}
// do our best to return something useful.
return inputMethod.toString() + "-" + inputMethod.getLocale().toString();
}
/**
* @see java.awt.im.spi.InputMethodContext#enableClientWindowNotification
*/
synchronized void enableClientWindowNotification(InputMethod requester,
boolean enable) {
// in case this request is not from the current input method,
// store the request and handle it when this requesting input
// method becomes the current one.
if (requester != inputMethod) {
if (perInputMethodState == null) {
perInputMethodState = new HashMap<>(5);
}
perInputMethodState.put(requester, Boolean.valueOf(enable));
return;
}
if (clientWindowNotificationEnabled != enable) {
clientWindowLocation = null;
clientWindowNotificationEnabled = enable;
}
if (clientWindowNotificationEnabled) {
if (!addedClientWindowListeners()) {
addClientWindowListeners();
}
if (clientWindowListened != null) {
clientWindowLocation = null;
notifyClientWindowChange(clientWindowListened);
}
} else {
if (addedClientWindowListeners()) {
removeClientWindowListeners();
}
}
}
/**
* @see java.awt.im.spi.InputMethodContext#enableClientWindowNotification
*/
synchronized void enableClientWindowNotification(InputMethod requester,
boolean enable) {
// in case this request is not from the current input method,
// store the request and handle it when this requesting input
// method becomes the current one.
if (requester != inputMethod) {
if (perInputMethodState == null) {
perInputMethodState = new HashMap<>(5);
}
perInputMethodState.put(requester, Boolean.valueOf(enable));
return;
}
if (clientWindowNotificationEnabled != enable) {
clientWindowLocation = null;
clientWindowNotificationEnabled = enable;
}
if (clientWindowNotificationEnabled) {
if (!addedClientWindowListeners()) {
addClientWindowListeners();
}
if (clientWindowListened != null) {
clientWindowLocation = null;
notifyClientWindowChange(clientWindowListened);
}
} else {
if (addedClientWindowListeners()) {
removeClientWindowListeners();
}
}
}
/**
* @see java.awt.im.InputContext#setCompositionEnabled(boolean)
* @exception UnsupportedOperationException when input method is null
*/
public void setCompositionEnabled(boolean enable) {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
inputMethod.setCompositionEnabled(enable);
}
/**
* @see java.awt.im.InputContext#reconvert
* @since 1.3
* @exception UnsupportedOperationException when input method is null
*/
public synchronized void reconvert() {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
inputMethod.reconvert();
}
/**
* @see java.awt.im.InputContext#setCompositionEnabled(boolean)
* @exception UnsupportedOperationException when input method is null
*/
public void setCompositionEnabled(boolean enable) {
InputMethod inputMethod = getInputMethod();
if (inputMethod == null) {
throw new UnsupportedOperationException();
}
inputMethod.setCompositionEnabled(enable);
}