diff --git a/make/sun/xawt/mapfile-vers b/make/sun/xawt/mapfile-vers
index 9e0b434b557361e0cb36de61d0ad7b45d7d80e6b..59c5577877382b205fc5ccd49cf246bf20847c13 100644
--- a/make/sun/xawt/mapfile-vers
+++ b/make/sun/xawt/mapfile-vers
@@ -151,6 +151,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl;
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl;
Java_sun_awt_X11_XRobotPeer_setup;
+ Java_sun_awt_X11_XRobotPeer_getNumberOfButtonsImpl;
Java_java_awt_Component_initIDs;
Java_java_awt_Container_initIDs;
Java_java_awt_Button_initIDs;
diff --git a/src/share/classes/java/awt/Robot.java b/src/share/classes/java/awt/Robot.java
index 2ce6a2686f1e381f33cefa726c613e48bfc73442..94c71283cee338bcfafe55ae63fd5201adeffd6a 100644
--- a/src/share/classes/java/awt/Robot.java
+++ b/src/share/classes/java/awt/Robot.java
@@ -70,10 +70,7 @@ public class Robot {
private RobotPeer peer;
private boolean isAutoWaitForIdle = false;
private int autoDelay = 0;
- private static final int LEGAL_BUTTON_MASK =
- InputEvent.BUTTON1_MASK|
- InputEvent.BUTTON2_MASK|
- InputEvent.BUTTON3_MASK;
+ private static int LEGAL_BUTTON_MASK;
// location of robot's GC, used in mouseMove(), getPixelColor() and captureScreenImage()
private Point gdLoc;
@@ -98,6 +95,19 @@ public class Robot {
}
init(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice());
+ int tmpMask = 0;
+ if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
+ for (int i = 0; i < peer.getNumberOfButtons(); i++){
+ tmpMask |= InputEvent.getMaskForButton(i+1);
+ }
+ }
+ tmpMask |= InputEvent.BUTTON1_MASK|
+ InputEvent.BUTTON2_MASK|
+ InputEvent.BUTTON3_MASK|
+ InputEvent.BUTTON1_DOWN_MASK|
+ InputEvent.BUTTON2_DOWN_MASK|
+ InputEvent.BUTTON3_DOWN_MASK;
+ LEGAL_BUTTON_MASK = tmpMask;
}
/**
@@ -187,18 +197,55 @@ public class Robot {
/**
* Presses one or more mouse buttons. The mouse buttons should
- * be released using the mouseRelease method.
+ * be released using the {@link #mouseRelease(int)} method.
+ *
+ * @param buttons the Button mask; a combination of one or more
+ * mouse button masks.
+ *
+ * It is allowed to use only a combination of valid values as a {@code buttons} parameter. + * A valid combination consists of {@code InputEvent.BUTTON1_DOWN_MASK}, + * {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK} + * and values returned by the + * {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)} method. * - * @param buttons the Button mask; a combination of one or more - * of these flags: + * The valid combination also depends on a + * {@link Toolkit#areExtraMouseButtonsEnabled() Toolkit.areExtraMouseButtonsEnabled()} value as follows: + *
+ * The following standard button masks are also accepted: *
InputEvent.BUTTON1_MASK
- * InputEvent.BUTTON2_MASK
- * InputEvent.BUTTON3_MASK
+ * + * It is allowed to use only a combination of valid values as a {@code buttons} parameter. + * A valid combination consists of {@code InputEvent.BUTTON1_DOWN_MASK}, + * {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK} + * and values returned by the + * {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)} method. + * + * The valid combination also depends on a + * {@link Toolkit#areExtraMouseButtonsEnabled() Toolkit.areExtraMouseButtonsEnabled()} value as follows: + *
+ * The following standard button masks are also accepted: *
InputEvent.BUTTON1_MASK
- * InputEvent.BUTTON2_MASK
- * InputEvent.BUTTON3_MASK
+ * + * java -Dsun.awt.enableExtraMouseButtons=false Application + *+ * Alternatively, the property could be set in the application by using the following code: + *
+ * System.setProperty("sun.awt.enableExtraMouseButtons", "true");
+ *
+ * before the {@code Toolkit} class initialization.
+ * If not set by the time of the {@code Toolkit} class initialization, this property will be
+ * initialized with {@code true}.
+ * Changing this value after the {@code Toolkit} class initialization will have no effect.
+ * + * The current value could be queried by using the + * {@code System.getProperty("sun.awt.enableExtraMouseButtons")} method. + * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true + * @return {@code true} if events from extra mouse buttons are allowed to be processed and posted; + * {@code false} otherwise + * @see System#getProperty(String propertyName) + * @see System#setProperty(String propertyName, String value) + * @see java.awt.EventQueue + * @since 1.7 + */ + public boolean areExtraMouseButtonsEnabled() throws HeadlessException { + return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled(); + } } diff --git a/src/share/classes/java/awt/doc-files/DesktopProperties.html b/src/share/classes/java/awt/doc-files/DesktopProperties.html index f699ba2fa7af79775e0423d4bd4842a67339d8d3..5f3afb37442b4575b77174bddf92207f42b347cc 100644 --- a/src/share/classes/java/awt/doc-files/DesktopProperties.html +++ b/src/share/classes/java/awt/doc-files/DesktopProperties.html @@ -1,5 +1,5 @@