-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.4
-
x86
-
windows_95
Name: rm29839 Date: 11/17/97
Compile the code below, then run it; in the edit box enter some DBCS and
hit ESC key, you will notice that the caret is always set at half of the size
of DBCS characters sequence.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Sample extends Applet {
TextField t1 = new TextField(30);
String s = new String();
public void init() {
t1.addKeyListener(new T1K());
add(t1);
}
class T1K extends KeyAdapter {
public void keyTyped(KeyEvent e) {
String ts = t1.getText();
if(e.getKeyChar() ==
KeyEvent.VK_ESCAPE) {
/t1.setText("\u4E0A\u5348\u4E0B\u5348");
// I want to set the caret to the end of the String.
// I can use either setCaretPosition or select
// In both cases, if I key in DBCS the caret will be wrong
t1.setCaretPosition(t1.getText().length());
// t1.select(t1.getText().length(),t1.getText().length());
}
}
}
static class WL extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
public static void main(String args[]) {
Sample applet = new Sample();
Frame aFrame = new Frame("Sample");
aFrame.addWindowListener(new WL());
aFrame.add(applet, BorderLayout.CENTER);
aFrame.setSize(300,100);
applet.init();
applet.start();
aFrame.setVisible(true);
}
}
(Review ID: 19767)
======================================================================
- duplicates
-
JDK-4066587 TextArea/Field: selectAll can not select all entry if multibyte is used
-
- Closed
-