private void setUserInputEnabled(boolean enable, boolean convertToAscii) {
    if (enable == isUserInputEnabled) return;
    isUserInputEnabled = enable;
    if (enable) {
      if (null == mouseEventListener) {
        mouseEventListener = new MouseEventListener(this, context);
      }
      addMouseListener(mouseEventListener);
      addMouseMotionListener(mouseEventListener);
      addMouseWheelListener(mouseEventListener);

      setFocusTraversalKeysEnabled(false);
      if (null == keyEventListener) {
        keyEventListener = new KeyEventListener(context);
        if (modifierButtonListener != null) {
          keyEventListener.addModifierListener(modifierButtonListener);
        }
      }
      keyEventListener.setConvertToAscii(convertToAscii);
      addKeyListener(keyEventListener);
      enableInputMethods(false);
    } else {
      removeMouseListener(mouseEventListener);
      removeMouseMotionListener(mouseEventListener);
      removeMouseWheelListener(mouseEventListener);
      removeKeyListener(keyEventListener);
    }
  }
 public void addModifierListener(ModifierButtonEventListener modifierButtonListener) {
   this.modifierButtonListener = modifierButtonListener;
   if (keyEventListener != null) {
     keyEventListener.addModifierListener(modifierButtonListener);
   }
 }