public void endComposition(){
  if (disposed) {
    return;
  }
  savedCompositionState=getCompositionState();
  boolean active=haveActiveClient();
  if (active && composedText == null && committedText == null) {
    needResetXIC=true;
    needResetXICClient=new WeakReference<>(getClientComponent());
    return;
  }
  String text=resetXIC();
  if (active) {
    needResetXIC=false;
  }
  awtLock();
  composedText=null;
  postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,null,0,null,null);
  if (text != null && text.length() > 0) {
    dispatchCommittedText(text);
  }
  awtUnlock();
  if (savedCompositionState) {
    resetCompositionState();
  }
}

public void endComposition ( ) { if ( disposed ) { return ; } savedCompositionState = getCompositionState ( ) ; boolean active = haveActiveClient ( ) ; if ( active && composedText == null && committedText == null ) { needResetXIC = true ; needResetXICClient = new WeakReference < > ( getClientComponent ( ) ) ; return ; } String text = resetXIC ( ) ; if ( active ) { needResetXIC = false ; } awtLock ( ) ; composedText = null ; postInputMethodEvent ( InputMethodEvent . INPUT_METHOD_TEXT_CHANGED , null , 0 , null , null ) ; if ( text != null && text . length ( ) > 0 ) { dispatchCommittedText ( text ) ; } awtUnlock ( ) ; if ( savedCompositionState ) { resetCompositionState ( ) ; } }
ends any input composition that may currently be going on in this context . depending on the platform and possibly user preferences , this may commit or delete uncommitted text . any changes to the text are communicated to the active component using an input method event . < p > a text editing component may call this in a variety of situations , for example , when the user moves the insertion point within the text ( but outside the composed text ) , or when the component ' s text is saved to a file or copied to the clipboard .
