Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class ActiveClient

java.lang.Object
  |
  +--java.awt.Component
        |
        +--LWTextComponent
              |
              +--ActiveClient

public class ActiveClient
extends LWTextComponent
implements java.awt.event.InputMethodListener, java.awt.im.InputMethodRequests
Implements on-the-spot text input, the most closely integrated form of interaction with input methods. This class is an active client of the input method framework, that is, actively uses its APIs to accomplish integration.

This class directly implements the two client interfaces of the input method framework, InputMethodListener and InputMethodRequests. This is not required. Especially in cases where the public interface matters (such as in a class library), it may be more appropriate to hide the implementations of these two interfaces in separate classes.

See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
ActiveClient(java.lang.String name)
          Constructs an ActiveClient.
 
Method Summary
java.text.AttributedCharacterIterator cancelLatestCommittedText(java.text.AttributedCharacterIterator.Attribute[] attributes)
          Returns null to indicate that the "Undo Commit" feature is not supported by this simple text component.
void caretPositionChanged(java.awt.event.InputMethodEvent event)
          Handles changes to the caret within composed text.
java.awt.font.TextHitInfo getCaret()
          Returns a text hit info indicating the current caret (insertion point).
java.text.AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, java.text.AttributedCharacterIterator.Attribute[] attributes)
          Gets an iterator providing access to the entire text and attributes contained in the text editing component except for uncommitted text.
java.text.AttributedCharacterIterator getDisplayText()
          Returns the text that the user has entered.
java.awt.im.InputMethodRequests getInputMethodRequests()
          Implements getInputMethodRequests for ActiveClient by returning "this".
int getInsertPositionOffset()
          Gets the offset of the insert position in the committed text contained in the text editing component.
java.awt.font.TextHitInfo getLocationOffset(int x, int y)
          Gets the offset within the composed text for the specified absolute x and y coordinates on the screen.
java.text.AttributedCharacterIterator getSelectedText(java.text.AttributedCharacterIterator.Attribute[] attributes)
          Gets the currently selected text from the text editing component.
java.awt.Rectangle getTextLocation(java.awt.font.TextHitInfo offset)
          Gets the location of a specified offset in the current composed text, or of the selection in committed text.
void inputMethodTextChanged(java.awt.event.InputMethodEvent event)
          Handles changes to the text entered through an input method.
 
Methods inherited from class LWTextComponent
focusGained, focusLost, getCaret, getCaretRectangle, getCaretRectangle, getCommittedTextLength, getCommittedText, getCommittedText, getDisplayText, getTextLayout, getTextOrigin, insertCharacter, invalidateTextLayout, keyPressed, keyReleased, keyTyped, paint
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Constructor Detail

ActiveClient

public ActiveClient(java.lang.String name)
Constructs an ActiveClient. Input methods are always enabled for ActiveClient instances.
Parameters:
name - the component name to be displayed above the text
Method Detail

getInputMethodRequests

public java.awt.im.InputMethodRequests getInputMethodRequests()
Implements getInputMethodRequests for ActiveClient by returning "this".
Returns:
"this"
Overrides:
getInputMethodRequests in class java.awt.Component

getDisplayText

public java.text.AttributedCharacterIterator getDisplayText()
Returns the text that the user has entered. This override returns the concatenation of committed text and composed text.
Overrides:
getDisplayText in class LWTextComponent

getCaret

public java.awt.font.TextHitInfo getCaret()
Returns a text hit info indicating the current caret (insertion point). This override returns the caret provided by the input method while there is composed text; otherwise it returns a caret at the end of the committed text. The caret provided by the input method may be null.
Overrides:
getCaret in class LWTextComponent

inputMethodTextChanged

public void inputMethodTextChanged(java.awt.event.InputMethodEvent event)
Handles changes to the text entered through an input method. Committed text contained in the event is appended to the committed text of the text component. Composed text contained in the event replaces any existing composed text in the text component. The caret defined in the event is saved and will be returned by getCaret if there is composed text. The component is redrawn.

In this simple component, we only keep input method highlight attributes. Smarter components may want to keep language, reading, input method segment, and other attributes as well.

Specified by:
inputMethodTextChanged(java.awt.event.InputMethodEvent) in interface java.awt.event.InputMethodListener

caretPositionChanged

public void caretPositionChanged(java.awt.event.InputMethodEvent event)
Handles changes to the caret within composed text. The caret defined in the event is saved and will be returned by getCaret if there is composed text. The component is redrawn.
Specified by:
caretPositionChanged(java.awt.event.InputMethodEvent) in interface java.awt.event.InputMethodListener

getTextLocation

public java.awt.Rectangle getTextLocation(java.awt.font.TextHitInfo offset)
Gets the location of a specified offset in the current composed text, or of the selection in committed text.
Specified by:
getTextLocation(java.awt.font.TextHitInfo) in interface java.awt.im.InputMethodRequests

getLocationOffset

public java.awt.font.TextHitInfo getLocationOffset(int x,
                                     int y)
Gets the offset within the composed text for the specified absolute x and y coordinates on the screen.
Specified by:
getLocationOffset(int, int) in interface java.awt.im.InputMethodRequests

getInsertPositionOffset

public int getInsertPositionOffset()
Gets the offset of the insert position in the committed text contained in the text editing component. In this simple component, that's always at the end of the committed text.
Specified by:
getInsertPositionOffset() in interface java.awt.im.InputMethodRequests

getCommittedText

public java.text.AttributedCharacterIterator getCommittedText(int beginIndex,
                                                    int endIndex,
                                                    java.text.AttributedCharacterIterator.Attribute[] attributes)
Gets an iterator providing access to the entire text and attributes contained in the text editing component except for uncommitted text.
Specified by:
getCommittedText(int, int, java.text.AttributedCharacterIterator.Attribute[]) in interface java.awt.im.InputMethodRequests

cancelLatestCommittedText

public java.text.AttributedCharacterIterator cancelLatestCommittedText(java.text.AttributedCharacterIterator.Attribute[] attributes)
Returns null to indicate that the "Undo Commit" feature is not supported by this simple text component.
Specified by:
cancelLatestCommittedText(java.text.AttributedCharacterIterator.Attribute[]) in interface java.awt.im.InputMethodRequests

getSelectedText

public java.text.AttributedCharacterIterator getSelectedText(java.text.AttributedCharacterIterator.Attribute[] attributes)
Gets the currently selected text from the text editing component. Since this simple text component doesn't support selections, this is always an iterator over empty text.
Specified by:
getSelectedText(java.text.AttributedCharacterIterator.Attribute[]) in interface java.awt.im.InputMethodRequests

Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD