FileDocCategorySizeDatePackage
SimpleInputMethod.javaAPI DocExample6872Thu May 17 12:32:28 BST 2001com.ora.intl.ime

SimpleInputMethod

public class SimpleInputMethod extends Object implements InputMethod

Fields Summary
private static Window
statusWindow
private InputMethodContext
inputMethodContext
private Locale
locale
Constructors Summary
public SimpleInputMethod()

    // Set locale to Hebrew
    locale = new Locale("iw", "IL");
  
Methods Summary
public voidactivate()

    if (!statusWindow.isVisible()) {
      statusWindow.setVisible(true);
    }
  
public voiddeactivate(boolean isTemporary)

  
public voiddispatchEvent(java.awt.AWTEvent event)

    if (event.getID() == KeyEvent.KEY_TYPED) {
      KeyEvent e = (KeyEvent) event;
      if (handleCharacter(e.getKeyChar())) {
        e.consume();
      }
    }
  
public voiddispose()

  
public voidendComposition()

  
public java.lang.ObjectgetControlObject()

    return null;
  
public java.util.LocalegetLocale()

    return locale;
  
private booleanhandleCharacter(char ch)

    switch(ch) {
      case 'a":
        write('\u05D0"); // Hebrew Letter Aleph
        return true;
      case 'b":
        write('\u05D1"); // Hebrew Letter Bet
        return true;
      case 'g":
        write('\u05D2"); // Hebrew Letter Gimmel
        return true;
      case 'd":
        write('\u05D3"); // Hebrew Letter Dalet
        return true;
      case 'h":
        write('\u05D4"); // Hebrew Letter He
        return true;
      case 'v":
        write('\u05D5"); // Hebrew Letter Vav
        return true;
      case 'z":
        write('\u05D6"); // Hebrew Letter Zayin
        return true;
      case 'k":
        write('\u05D7"); // Hebrew Letter Het
        return true;
      case 'j":
        write('\u05D8"); // Hebrew Letter Tet
        return true;
      case 'y":
        write('\u05D9"); // Hebrew Letter Yod
        return true;
      case '\'":
        write('\u05DA"); // Hebrew Letter Final Kaf
        return true;
      case 'c":
        write('\u05DB"); // Hebrew Letter Kaf
        return true;
      case 'l":
        write('\u05DC"); // Hebrew Letter Lamed
        return true;
      case '.":
        write('\u05DD"); // Hebrew Letter Final Mem
        return true;
      case 'm":
        write('\u05DE"); // Hebrew Letter Mem
        return true;
      case ',":
        write('\u05DF"); // Hebrew Letter Final Nun
        return true;
      case 'n":
        write('\u05E0"); // Hebrew Letter Nun
        return true;
      case 's":
        write('\u05E1"); // Hebrew Letter Samekh
        return true;
      case 'i":
        write('\u05E2"); // Hebrew Letter Ayin
        return true;
      case 'p":
        write('\u05E3"); // Hebrew Letter Final Pe
        return true;
      case 'f":
        write('\u05E4"); // Hebrew Letter Pe
        return true;
      case ';":
        write('\u05E5"); // Hebrew Letter Final Tsadi
        return true;
      case 'x":
        write('\u05E6"); // Hebrew Letter Tsadi
        return true;
      case 'q":
        write('\u05E7"); // Hebrew Letter Qof
        return true;
      case 'r":
        write('\u05E8"); // Hebrew Letter Resh
        return true;
      case 'w":
        write('\u05E9"); // Hebrew Letter Shin
        return true;
      case 't":
        write('\u05EA"); // Hebrew Letter Tav
        return true;
    }
    return false;
  
public voidhideWindows()

    statusWindow.hide();
  
public booleanisCompositionEnabled()

    return true;
  
public voidnotifyClientWindowChange(java.awt.Rectangle location)

  
public voidreconvert()

    throw new UnsupportedOperationException();
  
public voidremoveNotify()

  
public voidsetCharacterSubsets(java.lang.Character$Subset[] subsets)

  
public voidsetCompositionEnabled(boolean enable)

    throw new UnsupportedOperationException();
  
public voidsetInputMethodContext(java.awt.im.spi.InputMethodContext context)

    inputMethodContext = context;
    if (statusWindow == null) {
      statusWindow = context.createInputMethodWindow("Simple Input Method",
                                                     false);
      Label label = new Label();
      label.setBackground(Color.lightGray);
      label.setText(locale.getDisplayName() + "Input Method Active");
      statusWindow.add(label);
      label.setSize(200, 50);
      statusWindow.add(label);
      statusWindow.pack();

      Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
      statusWindow.setLocation(d.width - statusWindow.getWidth(),
                               d.height - statusWindow.getHeight());
    }
  
public booleansetLocale(java.util.Locale locale)

    return (locale.equals(this.locale));
  
private voidwrite(char ch)

    AttributedString as = new AttributedString(String.valueOf(ch));
    inputMethodContext.dispatchInputMethodEvent(
                                InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                                as.getIterator(),
                                1,
                                null,
                                null);