diff options
Diffstat (limited to 'javax/swing/text/DefaultCaret.java')
-rw-r--r-- | javax/swing/text/DefaultCaret.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/javax/swing/text/DefaultCaret.java b/javax/swing/text/DefaultCaret.java index de512c37f..0d00bf8d5 100644 --- a/javax/swing/text/DefaultCaret.java +++ b/javax/swing/text/DefaultCaret.java @@ -829,9 +829,12 @@ public class DefaultCaret extends Rectangle public void setDot(int dot) { if (dot >= 0) - { + { + Document doc = textComponent.getDocument(); + if (doc != null) + this.dot = Math.min(dot, doc.getLength()); + this.dot = Math.max(this.dot, 0); this.mark = dot; - this.dot = dot; handleHighlight(); adjustVisibility(this); appear(); |