FIX: SHIFT+BACKSPACE breaks cursor position in an AWT TextField (260053)



The information in this article applies to:

  • Microsoft SDK for Java 4.0
  • Microsoft virtual machine
  • Microsoft Visual J++ 6.0

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("abc");
		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.

REFERENCES

For more information about the latest service pack for Windows 2000, click the following article number to view the article in the Microsoft Knowledge Base:

260910 How to Obtain the Latest Windows 2000 Service Pack

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbAwtPkg kbBug kbfix kbJavaVM33xxfix kbWin2000sp1Fix KB260053