diff --git a/jdk/src/share/classes/javax/swing/text/GlyphPainter2.java b/jdk/src/share/classes/javax/swing/text/GlyphPainter2.java index 1e5403defe8..8b27ec93e4d 100644 --- a/jdk/src/share/classes/javax/swing/text/GlyphPainter2.java +++ b/jdk/src/share/classes/javax/swing/text/GlyphPainter2.java @@ -172,6 +172,11 @@ class GlyphPainter2 extends GlyphView.GlyphPainter { //italic carets and we do not. TextHitInfo hit = layout.hitTestChar(x - (float)alloc.getX(), 0); int pos = hit.getInsertionIndex(); + + if (pos == v.getEndOffset()) { + pos--; + } + biasReturn[0] = hit.isLeadingEdge() ? Position.Bias.Forward : Position.Bias.Backward; return pos + v.getStartOffset(); }