8049533: SwingUtilities.convertMouseEvent misses MouseWheelEvent.preciseWheelRotation

Reviewed-by: serb, pchelko
This commit is contained in:
Alexander Scherbatiy 2014-08-08 16:13:15 +04:00
parent 62bbf50825
commit 2d07a3650d
4 changed files with 67 additions and 3 deletions

View File

@ -938,7 +938,11 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo
final Point pt = new Point();
final Component c = getComponentToForwardTo(e, pt);
if (c == null) return;
c.dispatchEvent(new MouseWheelEvent(c, e.getID(), e.getWhen(), e.getModifiers(), pt.x, pt.y, e.getClickCount(), e.isPopupTrigger(), e.getScrollType(), e.getScrollAmount(), e.getWheelRotation()));
c.dispatchEvent(new MouseWheelEvent(c, e.getID(), e.getWhen(),
e.getModifiers(), pt.x, pt.y, e.getXOnScreen(), e.getYOnScreen(),
e.getClickCount(), e.isPopupTrigger(), e.getScrollType(),
e.getScrollAmount(), e.getWheelRotation(),
e.getPreciseWheelRotation()));
}
public void componentResized(final ComponentEvent e) {

View File

@ -1233,11 +1233,13 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
delegate, me.getID(), me.getWhen(),
me.getModifiers(),
me.getX(), me.getY(),
me.getXOnScreen(), me.getYOnScreen(),
me.getClickCount(),
me.isPopupTrigger(),
me.getScrollType(),
me.getScrollAmount(),
me.getWheelRotation());
me.getWheelRotation(),
me.getPreciseWheelRotation());
} else if (e instanceof MouseEvent) {
MouseEvent me = (MouseEvent) e;

View File

@ -374,7 +374,8 @@ public class SwingUtilities implements SwingConstants
sourceWheelEvent.isPopupTrigger(),
sourceWheelEvent.getScrollType(),
sourceWheelEvent.getScrollAmount(),
sourceWheelEvent.getWheelRotation());
sourceWheelEvent.getWheelRotation(),
sourceWheelEvent.getPreciseWheelRotation());
}
else if (sourceEvent instanceof MenuDragMouseEvent) {
MenuDragMouseEvent sourceMenuDragEvent = (MenuDragMouseEvent)sourceEvent;

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.MouseWheelEvent;
import javax.swing.SwingUtilities;
/**
* @test
* @bug 8049533
* @summary SwingUtilities.convertMouseEvent misses
* MouseWheelEvent.preciseWheelRotation
* @run main bug8049533
*/
public class bug8049533 {
private static final double PRECISE_WHEEL_ROTATION = 3.14;
public static void main(String[] args) {
Frame frame = new Frame();
Panel panel = new Panel();
frame.add(panel);
MouseWheelEvent event = new MouseWheelEvent(panel,
0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0,
2, // wheelRotation
PRECISE_WHEEL_ROTATION); // preciseWheelRotation
MouseWheelEvent convertedEvent = (MouseWheelEvent) SwingUtilities.
convertMouseEvent(event.getComponent(), event, null);
if (convertedEvent.getPreciseWheelRotation() != PRECISE_WHEEL_ROTATION) {
throw new RuntimeException("PreciseWheelRotation field is not copied!");
}
}
}