@@ -560,6 +560,8 @@ private static synchronized Map getEntities() {
560560
561561 // --- Lazy setting text ---------------------------------------------------
562562 private String pendingText ;
563+ private int pendingDot = -1 ;
564+
563565 private String currentText ;
564566 private boolean forceSetText ;
565567
@@ -587,8 +589,8 @@ public void keyPressed(KeyEvent e) {
587589 public void hierarchyChanged (HierarchyEvent e ) {
588590 if ((e .getChangeFlags () & HierarchyEvent .SHOWING_CHANGED ) != 0 ) {
589591 if (isShowing () && pendingText != null ) setText (pendingText );
592+ }
590593 }
591- }
592594 });
593595 }
594596
@@ -626,6 +628,11 @@ public void setShowPopup(boolean showPopup) {
626628 public boolean getShowPopup () {
627629 return showPopup ;
628630 }
631+
632+ public void setCaretPosition (int position ) {
633+ if (pendingText == null ) super .setCaretPosition (position );
634+ else pendingDot = position ;
635+ }
629636
630637 public void setText (String value ) {
631638 if (value == null ) return ;
@@ -653,6 +660,11 @@ public void setText(String value) {
653660 setDocument (getEditorKit ().createDefaultDocument ()); // Workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042872
654661 super .setText (newText );
655662
663+ if (pendingDot != -1 ) {
664+ try { setCaretPosition (pendingDot ); }
665+ catch (IllegalArgumentException ex ) {} // expected
666+ pendingDot = -1 ;
667+ }
656668 }
657669
658670 forceSetText = false ;
0 commit comments