Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4415175
Votes 0
Synopsis No easy way to globally change the DND gesture motion threshold
Category java:drag&drop
Reported Against 1.3
Release Fixed 1.5(tiger)
State 10-Fix Delivered, request for enhancement
Priority: 4-Low
Related Bugs 4731797 , 4876520 , 4890786
Submit Date 14-FEB-2001
Description




Problem
~~~~~~~
5 is way too small of a value for the gestureMotionThreshold, and there is no easy way to change it globally.

The safest way is to get the MouseDragGestureRecognizer from DragSource which invokes the java.awt.Toolkit to get the appropriate MouseDragGestureRecognizer for a given platform.  The value from here comes from Toolkit.getDesktopProperty() which cannot be changed (since the method Toolkit.setDesktopProperty is protected).

In Swing you can use the UIDefaults class to override certain default behavior, but not this.  With the drag motion threshold set at 5, you VERY often get a drag when you do not want one (especially at higher resolutions).  There is no easy way to change it w/o using your own DragSource and DragGestureRecognizer (which may have quirks on some platforms, since you are defeating the built in behavior).

Please allow either (a) some other way to get the gestureMotionThreshold or (b) make Toolkit.setDesktopProperty public, or (c) some other solution to this problem.

Thanks!
(Review ID: 112646) 
======================================================================
Work Around




None feasible -- Implment your own DragSource and DragGestureRecognizer and hope it works as expected on most platforms.
======================================================================
Evaluation
Commit to tiger for now. We may have time to do this for merlin if we
miraculously fix everything else first.
 xxxxx@xxxxx  2001-02-14





Actually, it's possible to implement one's own drag gesture
recognizer that would utilize any given drag gesture motion
threshold. For example, one could look at
javax.swing.plaf.basic.BasicDragGestureRecognizer.

It's reasonable to add a public method for setting the
property in question and update the AWT default drag gesture
recognizers in order that setting this property takes effect
in all subsequent drag operations.

 xxxxx@xxxxx   2003-02-28
======================================================================




The following CCC request was approved on June, 5, 2003.

 4415175: No easy way to globally change the DND gesture motion threshold
 
 Problem
 
 The AWT default mouse drag gesture recognizers [see
 java.awt.dnd.DragSource.createDefaultDragGestureRecognizer()]
 use a drag gesture motion threshold. Roughly speaking, this is
 a number of pixels hysterisis before drag is determined to have
 started when the mouse is being dragged.
  
 Prior to this fix the AWT default drag gesture recognizers used
 the value of the desktop property "DnD.gestureMotionThreshold"
 [see java.awt.Toolkit.getDesktopProperty()] if it was available,
 otherwise they used the default value 5. But the desktop property
 "DnD.gestureMotionThreshold" was never set, so the default value
 5 was always used.
  
 With the drag gesture motion threshold presetted the way described
 above, users could not change the drag threshold and one could often
 get a drag when they do not want it (especially at higher resolutions).
 
 
 Requestors
 Java Drag & Drop team,
 Robert Clevenger (Oracle)
 
 
 Solution
 
 With this fix the pertinent Windows system metrics and
 XSETTING property are mapped to the Java desktop property
 "DnD.gestureMotionThreshold".
  
 However, a way for setting the drag threshold by a Java user
 should be provided. On Windows, for example, there is no way
 for a user to change the desktop settings pertinent to the
 drag threshold. The drag threshold can even appear less than
 5. On X platforms, if there is no XSETTINGS, the hard-coded
 default drag threshold is employed.
  
 From the 2 variants: a method for setting the drag threshold
 and a system property specifying the drag theshold, the
 latter appears to be more convenient: users could specify
 the drag threshold when starting their Java programs;
 besides, the former would require some mechanism to keep
 track of whether or not the drag threshold has been set via
 that setter method.
  
 Continuing, the solution is to introduce the Java system
 property "awt.dnd.drag.threshold"; add the method "public
 static int getDragThreshold()" to the class
 java.awt.dnd.DragSource; recommend mouse drag gesture
 recognizers to use DragSource.getDragThreshold() [all as
 decsribed in the specification section] and update the AWT
 default drag gesture recognizers to follow this convention.
 
 
 Interface summary
 exported  external  method     public static int java.awt.dnd.DragSource.getDragThreshold()
                     property   awt.dnd.drag.threshold
                     class      java.awt.dnd.MouseDragGestureRecognizer
     
  
 Specification
 
 java.awt.dnd.DragSource:
     /**
      * Returns the drag gesture motion threshold. The drag gesture motion threshold
      * defines the recommended behavior for {@link MouseDragGestureRecognizer}s.
      * <p>
      * If the system property <code>awt.dnd.drag.threshold</code> is set to
      * a positive integer, this method returns the value of the system property;
      * otherwise if a pertinent desktop property is available and supported by
      * the implementation of the Java platform, this method returns the value of
      * that property; otherwise this method returns some default value.
      * The pertinent desktop property can be queried using
      * <code>java.awt.Toolkit.getDesktopProperty("DnD.gestureMotionThreshold")</code>.
      *
      * @return the drag gesture motion threshold
      * @see MouseDragGestureRecognizer
      * @since 1.5
      */
     public static int getDragThreshold()
  
     
 java.awt.dnd.MouseDragGestureRecognizer:
  
 *** 14,30 ****
   import java.awt.event.MouseMotionListener;
   
   /**
    * This abstract subclass of <code>DragGestureRecognizer</code>
    * defines a <code>DragGestureRecognizer</code>
 !  * for mouse based gestures.
    *
 !  * Each platform will implement its own concrete subclass of this class,
    * available via the Toolkit.createDragGestureRecognizer() method, 
    * to encapsulate
    * the recognition of the platform dependent mouse gesture(s) that initiate
    * a Drag and Drop operation.
    *
    * @author Laurence P. G. Cable
    * @version %R%.%L%
    *
    * @see java.awt.dnd.DragGestureListener
 --- 14,43 ----
   import java.awt.event.MouseMotionListener;
   
   /**
    * This abstract subclass of <code>DragGestureRecognizer</code>
    * defines a <code>DragGestureRecognizer</code>
 !  * for mouse-based gestures.
    *
 !  * Each platform implements its own concrete subclass of this class,
    * available via the Toolkit.createDragGestureRecognizer() method, 
    * to encapsulate
    * the recognition of the platform dependent mouse gesture(s) that initiate
    * a Drag and Drop operation.
 +  * <p>
 +  * Mouse drag gesture recognizers should honor the
 +  * drag gesture motion threshold, available through
 +  * {@link DragSource#getDragThreshold}.
 +  * A drag gesture should be recognized only when the distance
 +  * in either the horizontal or vertical direction between 
 +  * the location of the latest mouse dragged event and the 
 +  * location of the corresponding mouse button pressed event
 +  * is greater than the drag gesture motion threshold.
 +  * <p>
 +  * Drag gesture recognizers created with
 +  * {@link DragSource#createDefaultDragGestureRecognizer}
 +  * follow this convention.
    *
    * @author Laurence P. G. Cable
    * @version %R%.%L%
    *
    * @see java.awt.dnd.DragGestureListener
 
    
 Compatibility risk: low
 Mouse drag gesture recognizers will use the value returned
 from DragSource.getDragThreshold() as the drag threshold
 instead of the default hard-coded value. That value can be
 set by a user through the system property or a pertinent
 property of the native desktop. These changes will unlikely
 break existing applications.


 xxxxx@xxxxx   2003-06-09
======================================================================




Swing drag gesture recognizers will be updated
to follow the convention given in the spec of
java.awt.dnd.MouseDragGestureRecognizer under
4876520 (Swing drag gesture recognizers should
honor drag threshold).

 xxxxx@xxxxx   2003-06-10
======================================================================
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang