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

JSR204: Vertical cursor movement will cut a supplementary character.

XMLWordPrintable

    • b32
    • generic
    • generic
    • Verified

      Scrolling the cursor vertically in a JTextArea using the keyboard can put the cursor between 2 supplementary characters.

      For example,

      ab
      \uD800\uDC00

      1) Have the cursor start at the beginning of line 1.
      2) Scroll the cursor to the right by one unit so that it lands between "a" and "b".
      3) Scroll down with the arrow key and the dot position will indicate the cursor to be in position 4 which is between "\uD800" and "\uDC00", properly paired surrogates.

      The following test program demonstrates this if you follow the above directions.

      --------------------------------- Cut Here ------------------------------------------
      import javax.swing.*;
      import javax.swing.event.*;

      public class SimpleTest {

          public static void main(String[] args) {
              new SimpleTest();
          }

          public SimpleTest() {
              JFrame f = new JFrame();
              JTextArea textArea = new JTextArea();
              textArea.addCaretListener(new CaretListener() {
                  public void caretUpdate(CaretEvent e) {
                      System.out.println(e.getDot());
                  }
              });

              textArea.setText("ab\n\uD800\uDC00");

              f.getContentPane().add(textArea);

              f.setSize(250, 120);
              f.show();
          }
      }
      --------------------------------- Cut Here ------------------------------------------

      ###@###.### 2003-11-24

            joconnersunw John Oconner (Inactive)
            elousunw Edmund Lou (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: