5216N/A/*
5216N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
5216N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5216N/A *
5216N/A * This code is free software; you can redistribute it and/or modify it
5216N/A * under the terms of the GNU General Public License version 2 only, as
5216N/A * published by the Free Software Foundation. Oracle designates this
5216N/A * particular file as subject to the "Classpath" exception as provided
5216N/A * by Oracle in the LICENSE file that accompanied this code.
5216N/A *
5216N/A * This code is distributed in the hope that it will be useful, but WITHOUT
5216N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5216N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5216N/A * version 2 for more details (a copy is included in the LICENSE file that
5216N/A * accompanied this code).
5216N/A *
5216N/A * You should have received a copy of the GNU General Public License version
5216N/A * 2 along with this work; if not, write to the Free Software Foundation,
5216N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5216N/A *
5216N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5216N/A * or visit www.oracle.com if you need additional information or have any
5216N/A * questions.
5216N/A */
5216N/A
5216N/Aimport java.awt.Frame;
5216N/Aimport java.awt.event.InputEvent;
5216N/Aimport java.awt.event.MouseEvent;
5216N/Aimport java.awt.event.MouseWheelEvent;
5216N/A
5216N/Aimport javax.swing.SwingUtilities;
5216N/Aimport javax.swing.event.MenuDragMouseEvent;
5216N/A
5216N/A/**
5216N/A * @test
5216N/A * @bug 7170657
5216N/A * @author Sergey Bylokhov
5216N/A */
5216N/Apublic final class bug7170657 {
5216N/A
5216N/A private static boolean FAILED;
5216N/A
5216N/A public static void main(final String[] args) {
5216N/A final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK;
5216N/A
5216N/A Frame f = new Frame();
5216N/A
5216N/A MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
5216N/A 1, 1, 1);
5216N/A MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1,
5216N/A true, null, null);
5216N/A MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
5216N/A MouseEvent.NOBUTTON);
5216N/A
5216N/A test(f, mwe);
5216N/A test(f, mdme);
5216N/A test(f, me);
5216N/A
5216N/A if (FAILED) {
5216N/A throw new RuntimeException("Wrong mouse event");
5216N/A }
5216N/A }
5216N/A
5216N/A
5216N/A private static void test(final Frame frame, final MouseEvent me) {
5216N/A MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
5216N/A if (me.getModifiersEx() != newme.getModifiersEx()
5216N/A || me.getModifiers() != newme.getModifiers()) {
5216N/A fail(me, newme);
5216N/A }
5216N/A }
5216N/A
5216N/A private static void fail(final MouseEvent exp, final MouseEvent act) {
5216N/A System.err.println("Expected: " + exp);
5216N/A System.err.println("Actual: " + act);
5216N/A FAILED = true;
5216N/A }
5216N/A}