KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwt > awt > event > InputMethodEvent


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9
10    $Log: InputMethodEvent.java,v $
11    Revision 1.2 2004/04/16 10:19:06 dannaab
12    Misc bug fixes, InputMap implementation, preliminary undo support
13
14    Revision 1.1 2004/03/30 10:42:44 bobintetley
15    Many minor bug fixes, event improvements by Dan Naab. Full swing.Icon support
16
17
18 */

19
20 package swingwt.awt.event;
21
22 import java.text.AttributedCharacterIterator JavaDoc;
23
24 import swingwt.awt.AWTEvent;
25 import swingwt.awt.Component;
26 import swingwt.awt.font.TextHitInfo;
27
28 /**
29  * @author Dan Naab
30  */

31 public class InputMethodEvent extends AWTEvent
32 {
33     public static final int INPUT_METHOD_FIRST = 1100;
34     public static final int INPUT_METHOD_TEXT_CHANGED = INPUT_METHOD_FIRST;
35     public static final int CARET_POSITION_CHANGED = INPUT_METHOD_FIRST + 1;
36     public static final int INPUT_METHOD_LAST = INPUT_METHOD_FIRST + 1;
37
38     private AttributedCharacterIterator JavaDoc text;
39     private int committedCharacterCount;
40     private TextHitInfo caret;
41     private TextHitInfo visiblePosition;
42     private long when;
43
44     public InputMethodEvent( Component source, int id, AttributedCharacterIterator JavaDoc text, int committedCharacterCount,
45                              TextHitInfo caret, TextHitInfo visiblePosition )
46     {
47         this( source, id, 0, text, committedCharacterCount, caret, visiblePosition );
48     }
49
50     public InputMethodEvent( Component source, int id, long when, AttributedCharacterIterator JavaDoc text,
51                              int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition )
52     {
53         super(source, id);
54         this.text = text;
55         this.committedCharacterCount = committedCharacterCount;
56         this.caret = caret;
57         this.visiblePosition = visiblePosition;
58         this.when = when;
59     }
60
61     public InputMethodEvent( Component source, int id, TextHitInfo caret, TextHitInfo visiblePosition )
62     {
63         this( source, id, 0, null, 0, caret, visiblePosition );
64     }
65
66     public AttributedCharacterIterator JavaDoc getText() { return text; }
67     public int getCommittedCharacterCount() { return committedCharacterCount; }
68     public TextHitInfo getCaret() { return caret; }
69     public TextHitInfo getVisiblePosition() { return visiblePosition; }
70     public void consume() { consumed = true; }
71     public boolean isConsumed() { return consumed; }
72
73     public long getWhen()
74     {
75         throw new UnsupportedOperationException JavaDoc("getWhen (event time) is not implemented!");
76     }
77
78     public String JavaDoc paramString()
79     {
80         return toString();
81     }
82 }
83
Popular Tags