-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.1
-
None
-
x86
-
windows_nt
Name: sg39081 Date: 07/01/97
- derive a class from java.awt.TextArea implementing KeyListener.
- override processKeyEvent.
- in processKeyEvent if the user types in a VK_TAB then consume
the event and call TextArea.insert(" ", getCaretPosition());
- run the code and type in bunch of text including a couple
of VK_ENTER's.
- Go the the second line, first column and type a VK_TAB.
- the 4 spaces will get inserted incorrectly.
NOTE: same problem using getStartPosition() and getEndPosition()
EXAMPLE:
protected void processKeyEvent(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_UNDEFINED // KEY_PRESSED
&& e.getKeyChar() == KeyEvent.VK_TAB)
{
// insert 4 spaces at the current caret position
insert(" ", getCaretPosition());
e.consume();
}
}
======================================================================
- duplicates
-
JDK-4072264 getSelectedText, getSelectedStart/End in TextArea class returns wrong
-
- Closed
-