Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8049533

SwingUtilities.convertMouseEvent misses MouseWheelEvent.preciseWheelRotation

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u5
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b28
    • CPU:
      x86
    • OS:
      windows_7

      Backports

        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 ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  alexsch Alexander Scherbatiy (Inactive)
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: