268 *
269 * <dt><b>Newlines</b>
270 * <dd>
271 * For a discussion on how newlines are handled, see
272 * <a href="DefaultEditorKit.html">DefaultEditorKit</a>.
273 *
274 *
275 * <dt><b>Printing support</b>
276 * <dd>
277 * Several {@link #print print} methods are provided for basic
278 * document printing. If more advanced printing is needed, use the
279 * {@link #getPrintable} method.
280 * </dl>
281 *
282 * <p>
283 * <strong>Warning:</strong>
284 * Serialized objects of this class will not be compatible with
285 * future Swing releases. The current serialization support is
286 * appropriate for short term storage or RMI between applications running
287 * the same version of Swing. As of 1.4, support for long term storage
288 * of all JavaBeans™
289 * has been added to the <code>java.beans</code> package.
290 * Please see {@link java.beans.XMLEncoder}.
291 *
292 * @author Timothy Prinzing
293 * @author Igor Kushnirskiy (printing support)
294 * @see Document
295 * @see DocumentEvent
296 * @see DocumentListener
297 * @see Caret
298 * @see CaretEvent
299 * @see CaretListener
300 * @see TextUI
301 * @see View
302 * @see ViewFactory
303 */
304 @JavaBean(defaultProperty = "UI")
305 @SwingContainer(false)
306 @SuppressWarnings("serial") // Same-version serialization only
307 public abstract class JTextComponent extends JComponent implements Scrollable, Accessible
308 {
1113 if (keymapTable == null) {
1114 keymapTable = new HashMap<String,Keymap>(17);
1115 appContext.put(KEYMAP_TABLE, keymapTable);
1116 //initialize default keymap
1117 Keymap binding = addKeymap(DEFAULT_KEYMAP, null);
1118 binding.setDefaultAction(new
1119 DefaultEditorKit.DefaultKeyTypedAction());
1120 }
1121 return keymapTable;
1122 }
1123 }
1124
1125 /**
1126 * Binding record for creating key bindings.
1127 * <p>
1128 * <strong>Warning:</strong>
1129 * Serialized objects of this class will not be compatible with
1130 * future Swing releases. The current serialization support is
1131 * appropriate for short term storage or RMI between applications running
1132 * the same version of Swing. As of 1.4, support for long term storage
1133 * of all JavaBeans™
1134 * has been added to the <code>java.beans</code> package.
1135 * Please see {@link java.beans.XMLEncoder}.
1136 */
1137 @SuppressWarnings("serial") // Same-version serialization only
1138 public static class KeyBinding {
1139
1140 /**
1141 * The key.
1142 */
1143 public KeyStroke key;
1144
1145 /**
1146 * The name of the action for the key.
1147 */
1148 public String actionName;
1149
1150 /**
1151 * Creates a new key binding.
1152 *
1153 * @param key the key
2537 * <code>JTextComponent</code>
2538 */
2539 @BeanProperty(bound = false)
2540 public AccessibleContext getAccessibleContext() {
2541 if (accessibleContext == null) {
2542 accessibleContext = new AccessibleJTextComponent();
2543 }
2544 return accessibleContext;
2545 }
2546
2547 /**
2548 * This class implements accessibility support for the
2549 * <code>JTextComponent</code> class. It provides an implementation of
2550 * the Java Accessibility API appropriate to menu user-interface elements.
2551 * <p>
2552 * <strong>Warning:</strong>
2553 * Serialized objects of this class will not be compatible with
2554 * future Swing releases. The current serialization support is
2555 * appropriate for short term storage or RMI between applications running
2556 * the same version of Swing. As of 1.4, support for long term storage
2557 * of all JavaBeans™
2558 * has been added to the <code>java.beans</code> package.
2559 * Please see {@link java.beans.XMLEncoder}.
2560 */
2561 @SuppressWarnings("serial") // Same-version serialization only
2562 public class AccessibleJTextComponent extends AccessibleJComponent
2563 implements AccessibleText, CaretListener, DocumentListener,
2564 AccessibleAction, AccessibleEditableText,
2565 AccessibleExtendedText {
2566
2567 int caretPos;
2568 Point oldLocationOnScreen;
2569
2570 /**
2571 * Constructs an AccessibleJTextComponent. Adds a listener to track
2572 * caret change.
2573 */
2574 public AccessibleJTextComponent() {
2575 Document doc = JTextComponent.this.getDocument();
2576 if (doc != null) {
2577 doc.addDocumentListener(this);
|
268 *
269 * <dt><b>Newlines</b>
270 * <dd>
271 * For a discussion on how newlines are handled, see
272 * <a href="DefaultEditorKit.html">DefaultEditorKit</a>.
273 *
274 *
275 * <dt><b>Printing support</b>
276 * <dd>
277 * Several {@link #print print} methods are provided for basic
278 * document printing. If more advanced printing is needed, use the
279 * {@link #getPrintable} method.
280 * </dl>
281 *
282 * <p>
283 * <strong>Warning:</strong>
284 * Serialized objects of this class will not be compatible with
285 * future Swing releases. The current serialization support is
286 * appropriate for short term storage or RMI between applications running
287 * the same version of Swing. As of 1.4, support for long term storage
288 * of all JavaBeans
289 * has been added to the <code>java.beans</code> package.
290 * Please see {@link java.beans.XMLEncoder}.
291 *
292 * @author Timothy Prinzing
293 * @author Igor Kushnirskiy (printing support)
294 * @see Document
295 * @see DocumentEvent
296 * @see DocumentListener
297 * @see Caret
298 * @see CaretEvent
299 * @see CaretListener
300 * @see TextUI
301 * @see View
302 * @see ViewFactory
303 */
304 @JavaBean(defaultProperty = "UI")
305 @SwingContainer(false)
306 @SuppressWarnings("serial") // Same-version serialization only
307 public abstract class JTextComponent extends JComponent implements Scrollable, Accessible
308 {
1113 if (keymapTable == null) {
1114 keymapTable = new HashMap<String,Keymap>(17);
1115 appContext.put(KEYMAP_TABLE, keymapTable);
1116 //initialize default keymap
1117 Keymap binding = addKeymap(DEFAULT_KEYMAP, null);
1118 binding.setDefaultAction(new
1119 DefaultEditorKit.DefaultKeyTypedAction());
1120 }
1121 return keymapTable;
1122 }
1123 }
1124
1125 /**
1126 * Binding record for creating key bindings.
1127 * <p>
1128 * <strong>Warning:</strong>
1129 * Serialized objects of this class will not be compatible with
1130 * future Swing releases. The current serialization support is
1131 * appropriate for short term storage or RMI between applications running
1132 * the same version of Swing. As of 1.4, support for long term storage
1133 * of all JavaBeans
1134 * has been added to the <code>java.beans</code> package.
1135 * Please see {@link java.beans.XMLEncoder}.
1136 */
1137 @SuppressWarnings("serial") // Same-version serialization only
1138 public static class KeyBinding {
1139
1140 /**
1141 * The key.
1142 */
1143 public KeyStroke key;
1144
1145 /**
1146 * The name of the action for the key.
1147 */
1148 public String actionName;
1149
1150 /**
1151 * Creates a new key binding.
1152 *
1153 * @param key the key
2537 * <code>JTextComponent</code>
2538 */
2539 @BeanProperty(bound = false)
2540 public AccessibleContext getAccessibleContext() {
2541 if (accessibleContext == null) {
2542 accessibleContext = new AccessibleJTextComponent();
2543 }
2544 return accessibleContext;
2545 }
2546
2547 /**
2548 * This class implements accessibility support for the
2549 * <code>JTextComponent</code> class. It provides an implementation of
2550 * the Java Accessibility API appropriate to menu user-interface elements.
2551 * <p>
2552 * <strong>Warning:</strong>
2553 * Serialized objects of this class will not be compatible with
2554 * future Swing releases. The current serialization support is
2555 * appropriate for short term storage or RMI between applications running
2556 * the same version of Swing. As of 1.4, support for long term storage
2557 * of all JavaBeans
2558 * has been added to the <code>java.beans</code> package.
2559 * Please see {@link java.beans.XMLEncoder}.
2560 */
2561 @SuppressWarnings("serial") // Same-version serialization only
2562 public class AccessibleJTextComponent extends AccessibleJComponent
2563 implements AccessibleText, CaretListener, DocumentListener,
2564 AccessibleAction, AccessibleEditableText,
2565 AccessibleExtendedText {
2566
2567 int caretPos;
2568 Point oldLocationOnScreen;
2569
2570 /**
2571 * Constructs an AccessibleJTextComponent. Adds a listener to track
2572 * caret change.
2573 */
2574 public AccessibleJTextComponent() {
2575 Document doc = JTextComponent.this.getDocument();
2576 if (doc != null) {
2577 doc.addDocumentListener(this);
|