Microsoft KB Archive/260053

= FIX: SHIFT+BACKSPACE breaks cursor position in an AWT TextField =

Article ID: 260053

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Software Development Kit for Java 4.0
 * Microsoft Java Virtual Machine
 * Microsoft Visual J++ 6.0 Standard Edition

-



This article was previously published under Q260053



SYMPTOMS
When you press SHIFT+BACKSPACE in an AWT TextField, it does not erase characters as expected but moves the insertion point.



CAUSE
This is due to a bug in the Microsoft virtual machine.



STATUS
Microsoft has confirmed that this is a bug in Microsoft Visual J++ version 6.0, Microsoft SDK for Java version 4.0, and Microsoft virtual machine 3100 and 3200 series.

This problem was corrected in Windows 2000 Service Pack 1.



MORE INFORMATION
In an AWT TextField, the SHIFT+BACKSPACE combination is equivalent to the BACKSPACE key. However, when you press SHIFT+BACKSPACE, the cursor moves to the left one character. This does not appear until the user begins to type again.

Steps to Reproduce Behavior
The following Java code demonstrates this problem:

import java.applet.*; import java.awt.*; import java.awt.event.*;

public class Test extends Applet { public static void main (String argv[] ) { new MyFrame; }

public void init { new MyFrame; } }

class MyFrame extends Frame {

MyFrame { setLayout(new BorderLayout); TextField f1 = new TextField(&quot;abc&quot;); add(BorderLayout.NORTH, f1);

addWindowListener(new CloseAdapter); setBounds(100, 100, 200, 200); setVisible(true); } }

class CloseAdapter extends WindowAdapter { public void windowClosing (WindowEvent e) { System.exit(0); } }

Compile Test.java and type the following from the command line:

jview Test

In the text box, you can use the arrow keys to move the cursor to the end of the text string. Press SHIFT+BACKSPACE twice. Notice that the cursor does not move and nothing is erased. Now begin typing and notice that the insertion point has moved to the left two characters.

