United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7092551 Double-click in TextField sets caret to the beginning
JDK-7092551 : Double-click in TextField sets caret to the beginning

Details
Type:
Bug
Submit Date:
2011-09-20
Status:
Resolved
Updated Date:
2014-05-19
Project Name:
JDK
Resolved Date:
2012-06-12
Component:
client-libs
OS:
windows_7
Sub-Component:
java.awt
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
When double-clicking with the mouse in a java.awt.TextField the caret is set to the beginning. One would expect the selection of the word lying under the mouse cursor. Works fine with javax.swing.JTextField though.

REGRESSION.  Last worked in version 6u26

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
In the executable test case below, double-click anywhere in the TextField.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Word under the mouse cursor is selected.
ACTUAL -
Caret was set to the beginning.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.TextField;

public class TextFieldTest {
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			@Override
			public void run() {
				final Frame frame = new Frame();
				frame.add(new TextField("Lorem ipsum."));
				frame.pack();
				frame.setVisible(true);
			}
		});
	}
}
---------- END SOURCE ----------

                                    

Comments
EVALUATION

It is a regression in 6u10.
                                     
2011-09-21
EVALUATION

The AwtTextField class does not treat spaces and dots as text delimeters.
                                     
2011-11-17
EVALUATION

The root issues is that the RICHED20.DLL need to be loaded for the AwtTextField which contains the FINDWORDBREAK functionality.
                                     
2011-11-17
EVALUATION

I specified 6u10 above mistakenly.
                                     
2011-11-23
EVALUATION

The previous behaviour was that all mouse events were passed to the Windows EDIT component that handled them.

Now we have synthetic focuses and all events should handle manually.

The Windows EDIT control does not have find word break function so we do not get a word left and right breaks.

The suggested solution is to change the EDIT by RICHEDIT.
                                     
2012-01-27
EVALUATION

The solution is to use the RICHEDIT control for TextField instad of the EDIT.
So some unification for the AwtTextField and AwtTextArea classes is needed because they both will be based on the RICHEDIT control.
                                     
2012-04-05
EVALUATION

changeset: http://hg.openjdk.java.net/jdk8/awt/jdk/rev/a1d825c477bc
                                     
2012-06-08



Hardware and Software, Engineered to Work Together