All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.awt.event.InputMethodEvent Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
/*

NOTICE


(c) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.

Neither this file nor any files generated from it describe a complete specification, and they may only be used as described below. For example, no permission is given for you to incorporate this file, in whole or in part, in an implementation of a Java specification.

Sun Microsystems Inc. owns the copyright in this file and it is provided to you for informative, as opposed to normative, use. The file and any files generated from it may be used to generate other informative documentation, such as a unified set of documents of API signatures for a platform that includes technologies expressed as Java APIs. The file may also be used to produce "compilation stubs," which allow applications to be compiled and validated for such platforms.

Any work generated from this file, such as unified javadocs or compiled stub files, must be accompanied by this notice in its entirety.

This work corresponds to the API signatures of JSR 217: Personal Basis Profile 1.1. In the event of a discrepency between this work and the JSR 217 specification, which is available at http://www.jcp.org/en/jsr/detail?id=217, the latter takes precedence. */ package java.awt.event; import java.awt.AWTEvent; import java.awt.Component; import java.awt.EventQueue; import java.awt.font.TextHitInfo; import java.io.IOException; import java.io.ObjectInputStream; import java.lang.Integer; import java.text.AttributedCharacterIterator; import java.text.CharacterIterator; /** * Input method events contain information about text that is being * composed using an input method. Whenever the text changes, the * input method sends an event. If the text component that's currently * using the input method is an active client, the event is dispatched * to that component. Otherwise, it is dispatched to a separate * composition window. * *

* The text included with the input method event consists of two parts: * committed text and composed text. Either part may be empty. The two * parts together replace any uncommitted composed text sent in previous events, * or the currently selected committed text. * Committed text should be integrated into the text component's persistent * data, it will not be sent again. Composed text may be sent repeatedly, * with changes to reflect the user's editing operations. Committed text * always precedes composed text. * *

* Note: The timestamps used by this class report the difference, * measured in milliseconds, between the time of the event and midnight, * January 1, 1970 UTC * (similar to {@link java.lang.System.currentTimeMillis}). * * @author JavaSoft Asia/Pacific * @version 1.20 01/23/03 * @since 1.2 */ public class InputMethodEvent extends AWTEvent { /** * Serial Version ID. */ private static final long serialVersionUID = 4727190874778922661L; /** * Marks the first integer id for the range of input method event ids. */ public static final int INPUT_METHOD_FIRST = 1100; /** * The event type indicating changed input method text. This event is * generated by input methods while processing input. */ public static final int INPUT_METHOD_TEXT_CHANGED = 1100; /** * The event type indicating a changed insertion point in input method text. * This event is * generated by input methods while processing input if only the caret changed. */ public static final int CARET_POSITION_CHANGED = 1101; /** * Marks the last integer id for the range of input method event ids. */ public static final int INPUT_METHOD_LAST = 1101; /** * The time stamp that indicates when the event was created. * * @serial * @see #getWhen * @since 1.4 */ long when; /** * Constructs an InputMethodEvent with the specified * source component, type, time, text, caret, and visiblePosition. *

* The offsets of caret and visiblePosition are relative to the current * composed text; that is, the composed text within text * if this is an INPUT_METHOD_TEXT_CHANGED event, * the composed text within the text of the * preceding INPUT_METHOD_TEXT_CHANGED event otherwise. * * @param source the object where the event originated * @param id the event type * @param when a long integer that specifies the time the event occurred * @param text the combined committed and composed text, * committed text first; must be null * when the event type is CARET_POSITION_CHANGED; * may be null for * INPUT_METHOD_TEXT_CHANGED if there's no * committed or composed text * @param committedCharacterCount the number of committed * characters in the text * @param caret the caret (a.k.a. insertion point); * null if there's no caret within current * composed text * @param visiblePosition the position that's most important * to be visible; null if there's no * recommendation for a visible position within current * composed text * @exception IllegalArgumentException if id is not * in the range * INPUT_METHOD_FIRST..INPUT_METHOD_LAST; * or if id is CARET_POSITION_CHANGED and * text is not null; * or if committedCharacterCount is not in the range * 0..(text.getEndIndex() - text.getBeginIndex()) * * @since 1.4 */ public InputMethodEvent(Component source, int id, long when, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) { super(null, 0); } /** * Constructs an InputMethodEvent with the specified * source component, type, text, caret, and visiblePosition. *

* The offsets of caret and visiblePosition are relative to the current * composed text; that is, the composed text within text * if this is an INPUT_METHOD_TEXT_CHANGED event, * the composed text within the text of the * preceding INPUT_METHOD_TEXT_CHANGED event otherwise. * The time stamp for this event is initialized by invoking * {@link java.awt.EventQueue#getMostRecentEventTime()}. * * @param source the object where the event originated * @param id the event type * @param text the combined committed and composed text, * committed text first; must be null * when the event type is CARET_POSITION_CHANGED; * may be null for * INPUT_METHOD_TEXT_CHANGED if there's no * committed or composed text * @param committedCharacterCount the number of committed * characters in the text * @param caret the caret (a.k.a. insertion point); * null if there's no caret within current * composed text * @param visiblePosition the position that's most important * to be visible; null if there's no * recommendation for a visible position within current * composed text * @exception IllegalArgumentException if id is not * in the range * INPUT_METHOD_FIRST..INPUT_METHOD_LAST; * or if id is CARET_POSITION_CHANGED and * text is not null; * or if committedCharacterCount is not in the range * 0..(text.getEndIndex() - text.getBeginIndex()) */ public InputMethodEvent(Component source, int id, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) { super(null, 0); } /** * Constructs an InputMethodEvent with the * specified source component, type, caret, and visiblePosition. * The text is set to null, * committedCharacterCount to 0. *

* The offsets of caret and visiblePosition * are relative to the current composed text; that is, * the composed text within the text of the * preceding INPUT_METHOD_TEXT_CHANGED event if the * event being constructed as a CARET_POSITION_CHANGED event. * For an INPUT_METHOD_TEXT_CHANGED event without text, * caret and visiblePosition must be * null. * The time stamp for this event is initialized by invoking * {@link java.awt.EventQueue#getMostRecentEventTime()}. * * @param source the object where the event originated * @param id the event type * @param caret the caret (a.k.a. insertion point); * null if there's no caret within current * composed text * @param visiblePosition the position that's most important * to be visible; null if there's no * recommendation for a visible position within current * composed text * @exception IllegalArgumentException if id is not * in the range * INPUT_METHOD_FIRST..INPUT_METHOD_LAST */ public InputMethodEvent(Component source, int id, TextHitInfo caret, TextHitInfo visiblePosition) { super(null, 0); } /** * Gets the combined committed and composed text. * Characters from index 0 to index getCommittedCharacterCount() - 1 are committed * text, the remaining characters are composed text. * * @return the text. * Always null for CARET_POSITION_CHANGED; * may be null for INPUT_METHOD_TEXT_CHANGED if there's no composed or committed text. */ public AttributedCharacterIterator getText() { return null; } /** * Gets the number of committed characters in the text. */ public int getCommittedCharacterCount() { return 0; } /** * Gets the caret. *

* The offset of the caret is relative to the current * composed text; that is, the composed text within getText() * if this is an INPUT_METHOD_TEXT_CHANGED event, * the composed text within getText() of the * preceding INPUT_METHOD_TEXT_CHANGED event otherwise. * * @return the caret (a.k.a. insertion point). * Null if there's no caret within current composed text. */ public TextHitInfo getCaret() { return null; } /** * Gets the position that's most important to be visible. *

* The offset of the visible position is relative to the current * composed text; that is, the composed text within getText() * if this is an INPUT_METHOD_TEXT_CHANGED event, * the composed text within getText() of the * preceding INPUT_METHOD_TEXT_CHANGED event otherwise. * * @return the position that's most important to be visible. * Null if there's no recommendation for a visible position within current composed text. */ public TextHitInfo getVisiblePosition() { return null; } /** * Consumes this event so that it will not be processed * in the default manner by the source which originated it. */ public void consume() { } /** * Returns whether or not this event has been consumed. * @see #consume */ public boolean isConsumed() { return false; } /** * Returns the time stamp of when this event occurred. * * @return this event's timestamp * @since 1.4 */ public long getWhen() { return -1; } /** * Returns a parameter string identifying this event. * This method is useful for event-logging and for debugging. * It contains the event ID in text form, the characters of the * committed and composed text * separated by "+", the number of committed characters, * the caret, and the visible position. * * @return a string identifying the event and its attributes */ public String paramString() { return null; } /** * Initializes the when field if it is not present in the * object input stream. In that case, the field will be initialized by * invoking {@link java.awt.EventQueue#getMostRecentEventTime()}. */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy