Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8330462

StringIndexOutOfBoundException when typing anything into TextField

XMLWordPrintable

        A StringIndexOutOfBoundException occurs when typing anything into a JavaFX TextField in both JDK21 and JDK8, Windows11.

        Exception in thread "JavaFX Application Thread" java.lang.StringIndexOutOfBoundsException: Range [1, -2147483648) out of bounds for length 1
            at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
            at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
            at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
            at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
            at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
            at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
            at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
            at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4861)
            at java.base/java.lang.String.substring(String.java:2830)
            at javafx.graphics@21/com.sun.glass.ui.win.WinTextRangeProvider.GetText(WinTextRangeProvider.java:367)
            at javafx.graphics@21/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
            at javafx.graphics@21/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
            at java.base/java.lang.Thread.run(Thread.java:1583)

        More details can be found at https://stackoverflow.com/questions/78332309/stringindexoutofboundexception-occurs-when-typing-anything-into-a-javafx-textfie

        A reproducer was added by Jose as a comment below.

              arapte Ambarish Rapte
              cstein Christian Stein
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: