diff options
author | Guilhem Lavaux <guilhem@kaffe.org> | 2006-07-09 16:59:05 +0000 |
---|---|---|
committer | Guilhem Lavaux <guilhem@kaffe.org> | 2006-07-09 16:59:05 +0000 |
commit | 8f2887fc8c74aae0d541cbd59ea36c37d420267d (patch) | |
tree | adfecf70948384fcc6aa9cae41103dc4551d1b53 /javax/swing/text/DefaultCaret.java | |
parent | 4714fb23de2d811f49438611ac0d13ccd302e1ea (diff) | |
download | classpath-8f2887fc8c74aae0d541cbd59ea36c37d420267d.tar.gz |
2006-07-09 Guilhem Lavaux <guilhem@kaffe.org>
* Merged HEAD as of 2006-06-09 0:00.
Diffstat (limited to 'javax/swing/text/DefaultCaret.java')
-rw-r--r-- | javax/swing/text/DefaultCaret.java | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/javax/swing/text/DefaultCaret.java b/javax/swing/text/DefaultCaret.java index 4ad204c00..7b4335e40 100644 --- a/javax/swing/text/DefaultCaret.java +++ b/javax/swing/text/DefaultCaret.java @@ -221,9 +221,12 @@ public class DefaultCaret extends Rectangle if (name.equals("document")) { Document oldDoc = (Document) e.getOldValue(); - oldDoc.removeDocumentListener(documentListener); + if (oldDoc != null) + oldDoc.removeDocumentListener(documentListener); + Document newDoc = (Document) e.getNewValue(); - newDoc.addDocumentListener(documentListener); + if (newDoc != null) + newDoc.addDocumentListener(documentListener); } else if (name.equals("editable")) { @@ -708,7 +711,11 @@ public class DefaultCaret extends Rectangle propertyChangeListener = new PropertyChangeHandler(); textComponent.addPropertyChangeListener(propertyChangeListener); documentListener = new DocumentHandler(); - textComponent.getDocument().addDocumentListener(documentListener); + + Document doc = textComponent.getDocument(); + if (doc != null) + doc.addDocumentListener(documentListener); + active = textComponent.isEditable() && textComponent.isEnabled(); repaint(); @@ -1140,6 +1147,24 @@ public class DefaultCaret extends Rectangle } /** + * Returns <code>true</code> if this <code>Caret</code> is blinking, + * and <code>false</code> if not. The returned value is independent of + * the visiblity of this <code>Caret</code> as returned by {@link #isVisible()}. + * + * @return <code>true</code> if this <code>Caret</code> is blinking, + * and <code>false</code> if not. + * @see #isVisible() + * @since 1.5 + */ + public boolean isActive() + { + if (blinkTimer != null) + return blinkTimer.isRunning(); + + return false; + } + + /** * Returns <code>true</code> if this <code>Caret</code> is currently visible, * and <code>false</code> if it is not. * |