-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
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
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
- relates to
-
JDK-4904691 Cursor in JTextComponent doesn't track through supplementary chars
- Closed