1. /*
  2. * @(#)InputMethodContext.java 1.16 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.im.spi;
  8. import java.awt.HeadlessException;
  9. import java.awt.Window;
  10. import java.awt.font.TextHitInfo;
  11. import java.awt.im.InputMethodRequests;
  12. import java.text.AttributedCharacterIterator;
  13. import javax.swing.JFrame;
  14. /**
  15. * Provides methods that input methods
  16. * can use to communicate with their client components or to request
  17. * other services. This interface is implemented by the input method
  18. * framework, and input methods call its methods on the instance they
  19. * receive through
  20. * {@link java.awt.im.spi.InputMethod#setInputMethodContext}.
  21. * There should be no other implementors or callers.
  22. *
  23. * @since 1.3
  24. *
  25. * @version 1.16, 12/19/03
  26. * @author JavaSoft International
  27. */
  28. public interface InputMethodContext extends InputMethodRequests {
  29. /**
  30. * Creates an input method event from the arguments given
  31. * and dispatches it to the client component. For arguments,
  32. * see {@link java.awt.event.InputMethodEvent#InputMethodEvent}.
  33. */
  34. public void dispatchInputMethodEvent(int id,
  35. AttributedCharacterIterator text, int committedCharacterCount,
  36. TextHitInfo caret, TextHitInfo visiblePosition);
  37. /**
  38. * Creates a top-level window for use by the input method.
  39. * The intended behavior of this window is:
  40. * <ul>
  41. * <li>it floats above all document windows and dialogs
  42. * <li>it and all components that it contains do not receive the focus
  43. * <li>it has lightweight decorations, such as a reduced drag region without title
  44. * </ul>
  45. * However, the actual behavior with respect to these three items is platform dependent.
  46. * <p>
  47. * The title may or may not be displayed, depending on the actual type of window created.
  48. * <p>
  49. * If attachToInputContext is true, the new window will share the input context that
  50. * corresponds to this input method context, so that events for components in the window
  51. * are automatically dispatched to the input method.
  52. * Also, when the window is opened using setVisible(true), the input context will prevent
  53. * deactivate and activate calls to the input method that might otherwise be caused.
  54. * <p>
  55. * Input methods must call {@link java.awt.Window#dispose() Window.dispose} on the
  56. * returned input method window when it is no longer needed.
  57. * <p>
  58. * @param title the title to be displayed in the window's title bar,
  59. * if there is such a title bar.
  60. * A <code>null</code> value is treated as an empty string, "".
  61. * @param attachToInputContext whether this window should share the input context
  62. * that corresponds to this input method context
  63. * @return a window with special characteristics for use by input methods
  64. * @exception HeadlessException if <code>GraphicsEnvironment.isHeadless
  65. * </code> returns <code>true</code>
  66. */
  67. public Window createInputMethodWindow(String title, boolean attachToInputContext);
  68. /**
  69. * Creates a top-level Swing JFrame for use by the input method.
  70. * The intended behavior of this window is:
  71. * <ul>
  72. * <li>it floats above all document windows and dialogs
  73. * <li>it and all components that it contains do not receive the focus
  74. * <li>it has lightweight decorations, such as a reduced drag region without title
  75. * </ul>
  76. * However, the actual behavior with respect to these three items is platform dependent.
  77. * <p>
  78. * The title may or may not be displayed, depending on the actual type of window created.
  79. * <p>
  80. * If attachToInputContext is true, the new window will share the input context that
  81. * corresponds to this input method context, so that events for components in the window
  82. * are automatically dispatched to the input method.
  83. * Also, when the window is opened using setVisible(true), the input context will prevent
  84. * deactivate and activate calls to the input method that might otherwise be caused.
  85. * <p>
  86. * Input methods must call {@link java.awt.Window#dispose() Window.dispose} on the
  87. * returned input method window when it is no longer needed.
  88. * <p>
  89. * @param title the title to be displayed in the window's title bar,
  90. * if there is such a title bar.
  91. * A <code>null</code> value is treated as an empty string, "".
  92. * @param attachToInputContext whether this window should share the input context
  93. * that corresponds to this input method context
  94. * @return a JFrame with special characteristics for use by input methods
  95. * @exception HeadlessException if <code>GraphicsEnvironment.isHeadless
  96. * </code> returns <code>true</code>
  97. *
  98. * @since 1.4
  99. */
  100. public JFrame createInputMethodJFrame(String title, boolean attachToInputContext);
  101. /**
  102. * Enables or disables notification of the current client window's
  103. * location and state for the specified input method. When
  104. * notification is enabled, the input method's {@link
  105. * java.awt.im.spi.InputMethod#notifyClientWindowChange
  106. * notifyClientWindowChange} method is called as described in that
  107. * method's specification. Notification is automatically disabled
  108. * when the input method is disposed.
  109. *
  110. * @param inputMethod the input method for which notifications are
  111. * enabled or disabled
  112. * @param enable true to enable, false to disable
  113. */
  114. public void enableClientWindowNotification(InputMethod inputMethod, boolean enable);
  115. }