JDK-4532513 : DefaultCaret requests focus for click and pressed causing input verifier to fire
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 4_fcs,1.4.0,1.4.0_01
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,solaris_8,windows_nt,windows_2000 generic,solaris_8,windows_nt,windows_2000
  • CPU: generic,x86,sparc
  • Submitted: 2001-11-28
  • Updated: 2022-03-04
  • Resolved: 2002-03-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.1 hopperFixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
DefaultCaret requests focus in mouseClick and mousePressed causing the
associated input verifier to fire twice.  Attached test program.  Click in
the center text field then click on the third text field.  Notice that
shouldYieldFocus is called twice.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper FIXED IN: hopper INTEGRATED IN: hopper VERIFIED IN: hopper-beta
14-06-2004

SUGGESTED FIX --- DefaultCaret.java Mon Dec 3 17:24:59 2001 *************** *** 293,311 **** int nclicks = e.getClickCount(); if (SwingUtilities.isLeftMouseButton(e)) { // mouse 1 behavior ! if (nclicks == 1) { ! adjustCaretAndFocus(e); ! } else { ! if(e.getClickCount() == 2) { ! Action a = new DefaultEditorKit.SelectWordAction(); ! a.actionPerformed(new ActionEvent(getComponent(), ! ActionEvent.ACTION_PERFORMED, null, e.getWhen(), e.getModifiers())); ! } else if(e.getClickCount() == 3) { ! Action a = new DefaultEditorKit.SelectLineAction(); ! a.actionPerformed(new ActionEvent(getComponent(), ! ActionEvent.ACTION_PERFORMED, null, e.getWhen(), e.getModifiers())); ! } ! } } else if (SwingUtilities.isMiddleMouseButton(e)) { // mouse 2 behavior if (nclicks == 1) { --- 293,307 ---- int nclicks = e.getClickCount(); if (SwingUtilities.isLeftMouseButton(e)) { // mouse 1 behavior ! if(e.getClickCount() == 2) { ! Action a = new DefaultEditorKit.SelectWordAction(); ! a.actionPerformed(new ActionEvent(getComponent(), ! ActionEvent.ACTION_PERFORMED, null, e.getWhen(), e.getModifiers())); ! } else if(e.getClickCount() == 3) { ! Action a = new DefaultEditorKit.SelectLineAction(); ! a.actionPerformed(new ActionEvent(getComponent(), ! ActionEvent.ACTION_PERFORMED, null, e.getWhen(), e.getModifiers())); ! } } else if (SwingUtilities.isMiddleMouseButton(e)) { // mouse 2 behavior if (nclicks == 1) { ----------------------- I have attached the webrev for this bug. ###@###.### 2002-03-05
05-03-2002

EVALUATION The only case when we have that click/press mouse problem. Is when the left mouse button is clicked. The solution is to do not ask for focus on left button click. (We did it anyway when button was pressed) ----------------------- After changing mouseClicked to not adjust the caret and focus we have realized that another minor update is needed. When drag and drop is enabled, mousePressed will not do anything if the press is over a selection since it could become a drag operation. However, if the mouse is then released without initiating a drag, the caret should be updated and focus requested. This used to be the case when mouseClicked handled did this work. Since it no longer does, we should watch for this case and handle it in mouseReleased. ###@###.### 2002-03-04
04-03-2002