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

IndexOutOfBoundsException happened when deleting a char from a TextArea

XMLWordPrintable

      (JavaFX 2.0 beta b28 + JDK 1.6.0_25 + WinXP SP3)

      IndexOutOfBoundsException happened when deleting a char from a TextArea if the contents of this TextArea have multiple lines.

      Below codes can be used to re-produce.

      1. Type "abc" in the TextArea, then, press <ENTER>
      2. Type "def" in the TextArea, then, press <BACKSPACE>

      You will see below exception message

      java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
      at java.util.ArrayList.RangeCheck(ArrayList.java:547)
      at java.util.ArrayList.get(ArrayList.java:322)
      at com.javafx.preview.control.TextArea.getParagraphInfoAt(TextArea.java:369)
      at com.javafx.preview.control.TextArea$TextAreaContent.delete(TextArea.java:152)
      at com.javafx.preview.control.TextInput.removeText(TextInput.java:314)
      at com.javafx.preview.control.TextInput.removeText(TextInput.java:298)
      at com.sun.javafx.scene.control.behavior.TextAreaBehavior.handleKeyPressedEvent(TextAreaBehavior.java:253)
      at com.sun.javafx.scene.control.behavior.TextInputBehavior$5.handle(TextInputBehavior.java:51)
      at com.sun.javafx.scene.control.behavior.TextInputBehavior$5.handle(TextInputBehavior.java:48)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:55)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:161)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
      at javafx.scene.Node$19.dispatchEvent(Node.java:5409)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
      at javafx.event.Event.fireEventImpl(Event.java:185)
      at javafx.event.Event.fireEvent(Event.java:175)
      at javafx.scene.Scene$KeyHandler.process(Scene.java:2241)
      at javafx.scene.Scene$KeyHandler.access$1300(Scene.java:2171)
      at javafx.scene.Scene.impl_processKeyEvent(Scene.java:1157)
      at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:1558)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:53)
      at com.sun.glass.ui.View.handleKeyEvent(View.java:246)
      at com.sun.glass.ui.View.notifyKey(View.java:529)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
      at com.sun.glass.ui.win.WinApplication$2.run(WinApplication.java:51)
      at java.lang.Thread.run(Thread.java:662)


      ---------- Codes for re-producing ------------
      import javafx.application.Application;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.stage.Stage;
      import com.javafx.preview.control.TextArea;

      /**
       *
       * @author lianqi.li
       */
      public class TextAreaIssue extends Application {
          @Override public void start(Stage stage) {
              final Group root = new Group();
              final Scene scene = new Scene(root, 800, 600);
              final TextArea ta = new TextArea();

              root.getChildren().addAll(ta);
              
              stage.setScene(scene);
              stage.setVisible(true);
          }

          public static void main(String[] args) {
              Application.launch(TextAreaIssue.class, args);
          }
      }

            lianqli Lianqi Li (Inactive)
            lianqli Lianqi Li (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: