< prev index next >

src/java.desktop/share/classes/javax/swing/text/JTextComponent.java

Print this page




 144  * with input methods. As a consequence, some key events do not reach the text
 145  * component because they are handled by an input method, and some text input
 146  * reaches the text component as committed text within an {@link
 147  * java.awt.event.InputMethodEvent} instead of as a key event.
 148  * The complete text input is the combination of the characters in
 149  * <code>keyTyped</code> key events and committed text in input method events.
 150  * <p>
 151  * The AWT listener model lets applications attach event listeners to
 152  * components in order to bind events to actions. Swing encourages the
 153  * use of keymaps instead of listeners, but maintains compatibility
 154  * with listeners by giving the listeners a chance to steal an event
 155  * by consuming it.
 156  * <p>
 157  * Keyboard event and input method events are handled in the following stages,
 158  * with each stage capable of consuming the event:
 159  *
 160  * <table class="striped">
 161  * <caption>Stages of keyboard and input method event handling</caption>
 162  * <thead>
 163  * <tr>
 164  * <th id="stage">Stage</th>
 165  * <th id="ke">KeyEvent</th>
 166  * <th id="ime">InputMethodEvent</th></tr>
 167  * </thead>
 168  * <tbody>
 169  * <tr><td headers="stage">1.   </td>
 170  *     <td headers="ke">input methods </td>
 171  *     <td headers="ime">(generated here)</td></tr>
 172  * <tr><td headers="stage">2.   </td>
 173  *     <td headers="ke">focus manager </td>
 174  *     <td headers="ime"></td>


 175  * </tr>
 176  * <tr>
 177  *     <td headers="stage">3.   </td>
 178  *     <td headers="ke">registered key listeners</td>
 179  *     <td headers="ime">registered input method listeners</tr>
 180  * <tr>
 181  *     <td headers="stage">4.   </td>
 182  *     <td headers="ke"></td>
 183  *     <td headers="ime">input method handling in JTextComponent</tr>
 184  * <tr>
 185  *     <td headers="stage">5.   </td><td headers="ke ime" colspan=2>keymap handling using the current keymap</td></tr>
 186  * <tr><td headers="stage">6.   </td><td headers="ke">keyboard handling in JComponent (e.g. accelerators, component navigation, etc.)</td>
 187  *     <td headers="ime"></td></tr>




 188  * </tbody>
 189  * </table>
 190  *
 191  * <p>
 192  * To maintain compatibility with applications that listen to key
 193  * events but are not aware of input method events, the input
 194  * method handling in stage 4 provides a compatibility mode for
 195  * components that do not process input method events. For these
 196  * components, the committed text is converted to keyTyped key events
 197  * and processed in the key event pipeline starting at stage 3
 198  * instead of in the input method event pipeline.
 199  * <p>
 200  * By default the component will create a keymap (named <b>DEFAULT_KEYMAP</b>)
 201  * that is shared by all JTextComponent instances as the default keymap.
 202  * Typically a look-and-feel implementation will install a different keymap
 203  * that resolves to the default keymap for those bindings not found in the
 204  * different keymap. The minimal bindings include:
 205  * <ul>
 206  * <li>inserting content into the editor for the
 207  *  printable keys.
 208  * <li>removing content with the backspace and del
 209  *  keys.
 210  * <li>caret movement forward and backward




 144  * with input methods. As a consequence, some key events do not reach the text
 145  * component because they are handled by an input method, and some text input
 146  * reaches the text component as committed text within an {@link
 147  * java.awt.event.InputMethodEvent} instead of as a key event.
 148  * The complete text input is the combination of the characters in
 149  * <code>keyTyped</code> key events and committed text in input method events.
 150  * <p>
 151  * The AWT listener model lets applications attach event listeners to
 152  * components in order to bind events to actions. Swing encourages the
 153  * use of keymaps instead of listeners, but maintains compatibility
 154  * with listeners by giving the listeners a chance to steal an event
 155  * by consuming it.
 156  * <p>
 157  * Keyboard event and input method events are handled in the following stages,
 158  * with each stage capable of consuming the event:
 159  *
 160  * <table class="striped">
 161  * <caption>Stages of keyboard and input method event handling</caption>
 162  * <thead>
 163  *   <tr>
 164  *     <th scope="col">Stage
 165  *     <th scope="col">KeyEvent
 166  *     <th scope="col">InputMethodEvent
 167  * </thead>
 168  * <tbody>
 169  *   <tr>
 170  *     <th scope="row">1.
 171  *     <td>input methods
 172  *     <td>(generated here)
 173  *   <tr>
 174  *     <th scope="row" headers="stage">2.
 175  *     <td>focus manager
 176  *     <td>
 177  *   </tr>
 178  *   <tr>
 179  *     <th scope="row">3.
 180  *     <td>registered key listeners
 181  *     <td>registered input method listeners
 182  *   <tr>
 183  *     <th scope="row">4.
 184  *     <td>
 185  *     <td>input method handling in JTextComponent
 186  *   <tr>
 187  *     <th scope="row">5.
 188  *     <td colspan=2>keymap handling using the current keymap
 189  *   <tr>
 190  *     <th scope="row">6.
 191  *     <td>keyboard handling in JComponent (e.g. accelerators, component
 192  *     navigation, etc.)
 193  *     <td>
 194  * </tbody>
 195  * </table>

 196  * <p>
 197  * To maintain compatibility with applications that listen to key
 198  * events but are not aware of input method events, the input
 199  * method handling in stage 4 provides a compatibility mode for
 200  * components that do not process input method events. For these
 201  * components, the committed text is converted to keyTyped key events
 202  * and processed in the key event pipeline starting at stage 3
 203  * instead of in the input method event pipeline.
 204  * <p>
 205  * By default the component will create a keymap (named <b>DEFAULT_KEYMAP</b>)
 206  * that is shared by all JTextComponent instances as the default keymap.
 207  * Typically a look-and-feel implementation will install a different keymap
 208  * that resolves to the default keymap for those bindings not found in the
 209  * different keymap. The minimal bindings include:
 210  * <ul>
 211  * <li>inserting content into the editor for the
 212  *  printable keys.
 213  * <li>removing content with the backspace and del
 214  *  keys.
 215  * <li>caret movement forward and backward


< prev index next >