JDK-8049533 : SwingUtilities.convertMouseEvent misses MouseWheelEvent.preciseWheelRotation
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u5
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86
  • Submitted: 2014-07-07
  • Updated: 2014-08-29
  • Resolved: 2014-08-08
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.
JDK 9
9 b28Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
In 1.7 a new field, preciseWheelRotation, was added to MouseWheelEvent. SwingUtilities.convertMouseEvent misses this, creating a new MouseWheelEvent without preserving the precise value.

Additionally, the javadoc for that method could use a bit of cleanup: aesthetically, technically, and grammatically. Among other things, it makes reference to a method "translateMouseEvent" which doesn't seem to exist.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.event.MouseWheelEvent;
import javax.swing.*;

public class PreciseWheelRotationBug {
    public static void main(String[] args) {
        // need to provide a source component connected to hierarchy
        // or coordinate conversion throws an exception
        JFrame frame = new JFrame();
        JPanel panel = new JPanel();
        frame.add(panel);
        
        MouseWheelEvent mwe = new MouseWheelEvent(panel,
            0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0,
            3, // wheelRotation
            3.14); // preciseWheelRotation
        
        MouseWheelEvent mwe2 = (MouseWheelEvent)
            SwingUtilities.convertMouseEvent(mwe.getComponent(), mwe, null);
        
        System.out.println(mwe.getPreciseWheelRotation() + " => " + mwe2.getPreciseWheelRotation());
        if (mwe2.getPreciseWheelRotation() == mwe.getPreciseWheelRotation()) {
            System.out.println("PASS");
        } else {
            System.out.println("FAIL");
        }
    }
}
---------- END SOURCE ----------


Comments
SwingUtilities.convertMouseEvent() should also copy preciseWheelRotation for MouseWheelEvent
10-07-2014