提交 8eddf32e 编写于 作者: L lana

Merge

/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
......@@ -237,12 +237,5 @@ abstract class ChangeListenerMap<L extends EventListener> {
*
* @return a real listener
*/
public final L extract(L listener) {
while (listener instanceof EventListenerProxy) {
@SuppressWarnings("unchecked")
EventListenerProxy<L> proxy = (EventListenerProxy<L>) listener;
listener = proxy.getListener();
}
return listener;
}
public abstract L extract(L listener);
}
/*
* Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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
......@@ -533,5 +533,15 @@ public class PropertyChangeSupport implements Serializable {
protected PropertyChangeListener newProxy(String name, PropertyChangeListener listener) {
return new PropertyChangeListenerProxy(name, listener);
}
/**
* {@inheritDoc}
*/
public final PropertyChangeListener extract(PropertyChangeListener listener) {
while (listener instanceof PropertyChangeListenerProxy) {
listener = ((PropertyChangeListenerProxy) listener).getListener();
}
return listener;
}
}
}
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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
......@@ -522,5 +522,15 @@ public class VetoableChangeSupport implements Serializable {
protected VetoableChangeListener newProxy(String name, VetoableChangeListener listener) {
return new VetoableChangeListenerProxy(name, listener);
}
/**
* {@inheritDoc}
*/
public final VetoableChangeListener extract(VetoableChangeListener listener) {
while (listener instanceof VetoableChangeListenerProxy) {
listener = ((VetoableChangeListenerProxy) listener).getListener();
}
return listener;
}
}
}
......@@ -792,7 +792,8 @@ public class SwingUtilities implements SwingConstants
* @return true if the left mouse button was active
*/
public static boolean isLeftMouseButton(MouseEvent anEvent) {
return (anEvent.getButton() == MouseEvent.BUTTON1);
return ((anEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0 ||
anEvent.getButton() == MouseEvent.BUTTON1);
}
/**
......@@ -802,7 +803,8 @@ public class SwingUtilities implements SwingConstants
* @return true if the middle mouse button was active
*/
public static boolean isMiddleMouseButton(MouseEvent anEvent) {
return (anEvent.getButton() == MouseEvent.BUTTON2);
return ((anEvent.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0 ||
anEvent.getButton() == MouseEvent.BUTTON2);
}
/**
......@@ -812,7 +814,8 @@ public class SwingUtilities implements SwingConstants
* @return true if the right mouse button was active
*/
public static boolean isRightMouseButton(MouseEvent anEvent) {
return (anEvent.getButton() == MouseEvent.BUTTON3);
return ((anEvent.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0 ||
anEvent.getButton() == MouseEvent.BUTTON3);
}
/**
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -40,12 +40,9 @@
package transparentruler;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.*;
import java.awt.GraphicsDevice.WindowTranslucency;
import java.awt.GraphicsEnvironment;
import static java.awt.GraphicsDevice.WindowTranslucency.*;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
......@@ -79,16 +76,32 @@ public class Ruler extends JFrame {
private static final int F_HEIGHT = 400;
private static final int F_WIDTH = (int) (F_HEIGHT * 1.618 + 0.5);
private static void checkTranslucencyMode(WindowTranslucency arg) {
private static boolean translucencySupported;
private static boolean transparencySupported;
private static boolean checkTranslucencyMode(WindowTranslucency arg) {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
if (!gd.isWindowTranslucencySupported(arg)) {
System.err.println("'" + arg
+ "' translucency mode isn't supported.");
System.exit(-1);
}
return gd.isWindowTranslucencySupported(arg);
}
public Shape buildShape() {
int h = getHeight();
int w = getWidth();
float a = (float) Math.hypot(h, w);
Float path = new java.awt.geom.Path2D.Float();
path.moveTo(0, 0);
path.lineTo(w, 0);
path.lineTo(0, h);
path.closePath();
path.moveTo(W, W);
path.lineTo(W, h - W * (a + h) / w);
path.lineTo(w - W * (a + w) / h, W);
path.closePath();
return path;
}
private final ComponentAdapter componentListener = new ComponentAdapter() {
/**
......@@ -97,36 +110,32 @@ public class Ruler extends JFrame {
*/
@Override
public void componentResized(ComponentEvent e) {
int h = getHeight();
int w = getWidth();
float a = (float) Math.hypot(h, w);
Float path = new java.awt.geom.Path2D.Float();
path.moveTo(0, 0);
path.lineTo(w, 0);
path.lineTo(0, h);
path.closePath();
path.moveTo(W, W);
path.lineTo(W, h - W * (a + h) / w);
path.lineTo(w - W * (a + w) / h, W);
path.closePath();
setShape(path);
// We do apply shape only if PERPIXEL_TRANSPARENT is supported
if (transparencySupported) {
setShape(buildShape());
}
}
};
private final Action exitAction = new AbstractAction("Exit") {
{
putValue(Action.MNEMONIC_KEY, KeyEvent.VK_X);
}
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
};
private final JPopupMenu jPopupMenu = new JPopupMenu();
{
jPopupMenu.add(new JMenuItem(exitAction));
}
/**
* Implements mouse-related behavior: window dragging and popup menu
* invocation
......@@ -157,6 +166,7 @@ public class Ruler extends JFrame {
}
}
};
/**
* Implements keyboard navigation. Arrows move by 5 pixels, Ctrl + arrows
* move by 50 pixels, Alt + arrows move by 1 pixel.
......@@ -201,10 +211,22 @@ public class Ruler extends JFrame {
@Override
protected void paintComponent(Graphics g) {
Graphics gg = g.create();
Graphics2D gg = (Graphics2D) g.create();
int w = getWidth();
int h = getHeight();
int hh = gg.getFontMetrics().getAscent();
// This is an approach to apply shape when PERPIXEL_TRANSPARENT
// isn't supported
if (!transparencySupported) {
gg.setBackground(new Color(0, 0, 0, 0));
gg.clearRect(0, 0, w, h);
gg.clip(buildShape());
gg.setBackground(Ruler.this.getBackground());
gg.clearRect(0, 0, w, h);
}
gg.setColor(FOREGROUND);
for (int x = 0; x < w * (h - 8) / h - 5; x += 5) {
boolean hi = x % 50 == 0;
......@@ -216,6 +238,7 @@ public class Ruler extends JFrame {
gg.drawString(number, x + 5 - ww / 2, 20 + hh);
}
}
gg.dispose();
}
});
......@@ -231,9 +254,17 @@ public class Ruler extends JFrame {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
checkTranslucencyMode(WindowTranslucency.PERPIXEL_TRANSLUCENT);
checkTranslucencyMode(WindowTranslucency.PERPIXEL_TRANSPARENT);
translucencySupported = checkTranslucencyMode(PERPIXEL_TRANSLUCENT);
transparencySupported = checkTranslucencyMode(PERPIXEL_TRANSPARENT);
if (!translucencySupported) {
System.err.println("This application requires "
+ "'PERPIXEL_TRANSLUCENT' translucency mode to "
+ "be supported.");
System.exit(-1);
}
Ruler ruler = new Ruler();
ruler.setVisible(true);
......
/*
* Copyright (c) 2012, 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.
*/
/*
* @test
* @bug 7148143
* @summary Tests ClassCastException for the PropertyChangeSupport class
* @author Sergey Malenkov
*/
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.EventListener;
import java.util.EventListenerProxy;
public class Test7148143 {
private static class CustomProxy
extends EventListenerProxy<EventListener>
implements PropertyChangeListener {
public CustomProxy() {
super(new EventListener() {
});
}
public void propertyChange(PropertyChangeEvent event) {
}
}
public static void main(String[] args) {
PropertyChangeListener listener = new CustomProxy();
PropertyChangeSupport support = new PropertyChangeSupport(listener);
support.addPropertyChangeListener(listener);
support.addPropertyChangeListener("foo", listener); // cast class exception
}
}
/*
* Copyright (c) 2012, 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.
*/
/*
* @test
* @bug 7148143
* @summary Tests ClassCastException for the VetoableChangeSupport class
* @author Sergey Malenkov
*/
import java.beans.PropertyChangeEvent;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
import java.util.EventListener;
import java.util.EventListenerProxy;
public class Test7148143 {
private static class CustomProxy
extends EventListenerProxy<EventListener>
implements VetoableChangeListener {
public CustomProxy() {
super(new EventListener() {
});
}
public void vetoableChange(PropertyChangeEvent event) {
}
}
public static void main(String[] args) {
VetoableChangeListener listener = new CustomProxy();
VetoableChangeSupport support = new VetoableChangeSupport(listener);
support.addVetoableChangeListener(listener);
support.addVetoableChangeListener("foo", listener); // cast class exception
}
}
/*
* Copyright (c) 2012, 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.
*/
/*
* @test
* @bug 4524490
* @summary Tests if in JFileChooser, ALT+L does not bring focus to 'Files' selection list in Motif LAF
* @library ../../regtesthelpers
* @build Util
* @author Konstantin Eremin
* @run main bug4524490
*/
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.*;
import sun.awt.OSInfo;
import sun.awt.SunToolkit;
public class bug4524490 {
private static JFileChooser fileChooser;
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
fileChooser = new JFileChooser();
fileChooser.showOpenDialog(null);
}
});
toolkit.realSync();
if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);
} else {
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L);
}
checkFocus();
}
private static void checkFocus() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JList list = (JList) Util.findSubComponent(fileChooser, "javax.swing.JList");
System.out.println("list focus: " + list.isFocusOwner());
if (!list.isFocusOwner()) {
throw new RuntimeException("Focus is not transfered to the Folders list.");
}
}
});
}
}
/*
* Copyright (c) 2012, 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.
*/
/*
* @test
* @bug 6209975
* @summary regression: JMenuItem icons overimposed on JMenuItem labels under Metal LAF
* @library ../../regtesthelpers
* @build Util
* @author Alexander Zuev
* @run main bug6209975
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import sun.awt.SunToolkit;
public class bug6209975 {
private static final ReturnObject RO1 = new ReturnObject();
private static final ReturnObject RO2 = new ReturnObject();
private static JMenu menu;
private static JButton button;
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(500);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
Point clickPoint = getButtonClickPoint();
robot.mouseMove(clickPoint.x, clickPoint.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
clickPoint = getMenuClickPoint();
robot.mouseMove(clickPoint.x, clickPoint.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (RO1.itsValue <= RO2.itsValue) {
throw new RuntimeException("Offset if the second icon is invalid.");
}
}
private static Point getButtonClickPoint() throws Exception {
final Point[] result = new Point[1];
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
Point p = button.getLocationOnScreen();
Dimension size = button.getSize();
result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
}
});
return result[0];
}
private static Point getMenuClickPoint() throws Exception {
final Point[] result = new Point[1];
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
Point p = menu.getLocationOnScreen();
Dimension size = menu.getSize();
result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
}
});
return result[0];
}
private static void createAndShowGUI() {
JFrame frame = new JFrame("Test6209975");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
frame.setLayout(new BorderLayout());
button = new JButton("Focus holder");
frame.add(button);
JMenuBar mb = new JMenuBar();
menu = new JMenu("File");
JMenuItem item;
item = new JMenuItem("Just a menu item");
item.setIcon(new MyIcon(RO1));
item.setHorizontalTextPosition(SwingConstants.LEADING);
menu.add(item);
item = new JMenuItem("Menu Item with another icon");
item.setIcon(new MyIcon(RO2));
item.setHorizontalTextPosition(SwingConstants.TRAILING);
menu.add(item);
mb.add(menu);
frame.setJMenuBar(mb);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocation(400, 300);
frame.setVisible(true);
}
public static class ReturnObject {
public volatile int itsValue;
}
public static class MyIcon implements Icon {
ReturnObject thisObject = null;
public MyIcon(ReturnObject ro) {
super();
thisObject = ro;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
Color color = g.getColor();
g.setColor(Color.BLACK);
g.fillRect(x, y, 10, 10);
g.setColor(color);
thisObject.itsValue = x;
}
public int getIconWidth() {
return 10;
}
public int getIconHeight() {
return 10;
}
}
}
/*
* Copyright (c) 2012, 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.
*/
/* @test
@bug 7146377
@summary closed/javax/swing/DataTransfer/4876520/bug4876520.java failed since b08 in jdk 8
@author Pavel Porvatov
*/
import sun.awt.SunToolkit;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class bug7146377 {
private static JLabel label;
private static JFrame frame;
private static volatile Point point;
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame = new JFrame();
label = new JLabel("A label");
label.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
checkEvent(e);
}
@Override
public void mousePressed(MouseEvent e) {
checkEvent(e);
}
@Override
public void mouseReleased(MouseEvent e) {
checkEvent(e);
}
@Override
public void mouseEntered(MouseEvent e) {
checkEvent(e);
}
@Override
public void mouseExited(MouseEvent e) {
checkEvent(e);
}
});
frame.add(label);
frame.setSize(200, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync();
// On Linux platforms realSync doesn't guaranties setSize completion
Thread.sleep(1000);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
point = label.getLocationOnScreen();
}
});
Robot robot = new Robot();
robot.setAutoDelay(200);
// Move mouse
for (int i = 0; i < 20; i++) {
robot.mouseMove(point.x + i, point.y + i);
}
for (int button : new int[]{InputEvent.BUTTON1_MASK, InputEvent.BUTTON2_MASK, InputEvent.BUTTON3_MASK}) {
robot.mouseMove(point.x, point.y);
// Mouse Drag
robot.mousePress(button);
for (int i = 0; i < 20; i++) {
robot.mouseMove(point.x + i, point.y + i);
}
robot.mouseRelease(button);
}
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.dispose();
}
});
System.out.println("Test passed");
}
private static void checkEvent(MouseEvent e) {
String eventAsStr = eventToString(e);
System.out.println("Checking event " + eventAsStr);
check("isLeftMouseButton", SwingUtilities.isLeftMouseButton(e), oldIsLeftMouseButton(e), eventAsStr);
check("isRightMouseButton", SwingUtilities.isRightMouseButton(e), oldIsRightMouseButton(e), eventAsStr);
check("isMiddleMouseButton", SwingUtilities.isMiddleMouseButton(e), oldIsMiddleMouseButton(e), eventAsStr);
}
private static void check(String methodName, boolean newValue, boolean oldValue, String eventAsStr) {
if (newValue != oldValue) {
throw new RuntimeException("Regression on " + methodName + ", newValue = " + newValue +
", oldValue = " + oldValue + ", e = " + eventAsStr);
}
}
private static String eventToString(MouseEvent e) {
StringBuilder result = new StringBuilder();
switch (e.getID()) {
case MouseEvent.MOUSE_PRESSED:
result.append("MOUSE_PRESSED");
break;
case MouseEvent.MOUSE_RELEASED:
result.append("MOUSE_RELEASED");
break;
case MouseEvent.MOUSE_CLICKED:
result.append("MOUSE_CLICKED");
break;
case MouseEvent.MOUSE_ENTERED:
result.append("MOUSE_ENTERED");
break;
case MouseEvent.MOUSE_EXITED:
result.append("MOUSE_EXITED");
break;
case MouseEvent.MOUSE_MOVED:
result.append("MOUSE_MOVED");
break;
case MouseEvent.MOUSE_DRAGGED:
result.append("MOUSE_DRAGGED");
break;
case MouseEvent.MOUSE_WHEEL:
result.append("MOUSE_WHEEL");
break;
default:
result.append("unknown type");
}
result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
result.append(", button = " + e.getButton());
return result.toString();
}
// Original implementation of SwingUtilities.isLeftMouseButton
private static boolean oldIsLeftMouseButton(MouseEvent e) {
return ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0);
}
// Original implementation of SwingUtilities.isMiddleMouseButton
private static boolean oldIsMiddleMouseButton(MouseEvent e) {
return ((e.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK);
}
// Original implementation of SwingUtilities.isRightMouseButton
private static boolean oldIsRightMouseButton(MouseEvent e) {
return ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册