src/share/classes/java/awt/event/InputEvent.java

Print this page
rev 10048 : 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
Reviewed-by:


 145      */
 146     public static final int BUTTON2_DOWN_MASK = 1 << 11;
 147 
 148     /**
 149      * The Mouse Button3 extended modifier constant.
 150      * @since 1.4
 151      */
 152     public static final int BUTTON3_DOWN_MASK = 1 << 12;
 153 
 154     /**
 155      * The AltGraph key extended modifier constant.
 156      * @since 1.4
 157      */
 158     public static final int ALT_GRAPH_DOWN_MASK = 1 << 13;
 159 
 160     /**
 161      * An array of extended modifiers for additional buttons.
 162      * @see getButtonDownMasks
 163      * There are twenty buttons fit into 4byte space.
 164      * one more bit is reserved for FIRST_HIGH_BIT.
 165      * @since 7.0
 166      */
 167     private static final int [] BUTTON_DOWN_MASK = new int [] { BUTTON1_DOWN_MASK,
 168                                                                BUTTON2_DOWN_MASK,
 169                                                                BUTTON3_DOWN_MASK,
 170                                                                1<<14, //4th phisical button (this is not a wheel!)
 171                                                                1<<15, //(this is not a wheel!)
 172                                                                1<<16,
 173                                                                1<<17,
 174                                                                1<<18,
 175                                                                1<<19,
 176                                                                1<<20,
 177                                                                1<<21,
 178                                                                1<<22,
 179                                                                1<<23,
 180                                                                1<<24,
 181                                                                1<<25,
 182                                                                1<<26,
 183                                                                1<<27,
 184                                                                1<<28,
 185                                                                1<<29,
 186                                                                1<<30};
 187 
 188     /**
 189      * A method to access an array of extended modifiers for additional buttons.
 190      * @since 7.0
 191      */
 192     private static int [] getButtonDownMasks(){
 193         return Arrays.copyOf(BUTTON_DOWN_MASK, BUTTON_DOWN_MASK.length);
 194     }
 195 
 196 
 197     /**
 198      * A method to obtain a mask for any existing mouse button.
 199      * The returned mask may be used for different purposes. Following are some of them:
 200      * <ul>
 201      * <li> {@link java.awt.Robot#mousePress(int) mousePress(buttons)} and
 202      *      {@link java.awt.Robot#mouseRelease(int) mouseRelease(buttons)}
 203      * <li> as a {@code modifiers} parameter when creating a new {@link MouseEvent} instance
 204      * <li> to check {@link MouseEvent#getModifiersEx() modifiersEx} of existing {@code MouseEvent}
 205      * </ul>
 206      * @param button is a number to represent a button starting from 1.
 207      * For example,
 208      * <pre>
 209      * int button = InputEvent.getMaskForButton(1);
 210      * </pre>


 220      *    <b>button </b>   <b>returned mask</b>
 221      *    {@link MouseEvent#BUTTON1 BUTTON1}  {@link MouseEvent#BUTTON1_DOWN_MASK BUTTON1_DOWN_MASK}
 222      *    {@link MouseEvent#BUTTON2 BUTTON2}  {@link MouseEvent#BUTTON2_DOWN_MASK BUTTON2_DOWN_MASK}
 223      *    {@link MouseEvent#BUTTON3 BUTTON3}  {@link MouseEvent#BUTTON3_DOWN_MASK BUTTON3_DOWN_MASK}
 224      * </PRE>
 225      * If a mouse has more than three enabled buttons then more values
 226      * are admissible (4, 5, etc.). There is no assigned constants for these extended buttons.
 227      * The button masks for the extra buttons returned by this method have no assigned names like the
 228      * first three button masks.
 229      * <p>
 230      * This method has the following implementation restriction.
 231      * It returns masks for a limited number of buttons only. The maximum number is
 232      * implementation dependent and may vary.
 233      * This limit is defined by the relevant number
 234      * of buttons that may hypothetically exist on the mouse but it is greater than the
 235      * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
 236      *
 237      * @return a mask for an existing mouse button.
 238      * @throws IllegalArgumentException if {@code button} is less than zero or greater than the number
 239      *         of button masks reserved for buttons
 240      * @since 7.0
 241      * @see java.awt.MouseInfo#getNumberOfButtons()
 242      * @see Toolkit#areExtraMouseButtonsEnabled()
 243      * @see MouseEvent#getModifiers()
 244      * @see MouseEvent#getModifiersEx()
 245      */
 246     public static int getMaskForButton(int button) {
 247         if (button <= 0 || button > BUTTON_DOWN_MASK.length) {
 248             throw new IllegalArgumentException("button doesn\'t exist " + button);
 249         }
 250         return BUTTON_DOWN_MASK[button - 1];
 251     }
 252 
 253     // the constant below MUST be updated if any extra modifier
 254     // bits are to be added!
 255     // in fact, it is undesirable to add modifier bits
 256     // to the same field as this may break applications
 257     // see bug# 5066958
 258     static final int FIRST_HIGH_BIT = 1 << 31;
 259 
 260     static final int JDK_1_3_MODIFIERS = SHIFT_DOWN_MASK - 1;




 145      */
 146     public static final int BUTTON2_DOWN_MASK = 1 << 11;
 147 
 148     /**
 149      * The Mouse Button3 extended modifier constant.
 150      * @since 1.4
 151      */
 152     public static final int BUTTON3_DOWN_MASK = 1 << 12;
 153 
 154     /**
 155      * The AltGraph key extended modifier constant.
 156      * @since 1.4
 157      */
 158     public static final int ALT_GRAPH_DOWN_MASK = 1 << 13;
 159 
 160     /**
 161      * An array of extended modifiers for additional buttons.
 162      * @see getButtonDownMasks
 163      * There are twenty buttons fit into 4byte space.
 164      * one more bit is reserved for FIRST_HIGH_BIT.
 165      * @since 1.7
 166      */
 167     private static final int [] BUTTON_DOWN_MASK = new int [] { BUTTON1_DOWN_MASK,
 168                                                                BUTTON2_DOWN_MASK,
 169                                                                BUTTON3_DOWN_MASK,
 170                                                                1<<14, //4th phisical button (this is not a wheel!)
 171                                                                1<<15, //(this is not a wheel!)
 172                                                                1<<16,
 173                                                                1<<17,
 174                                                                1<<18,
 175                                                                1<<19,
 176                                                                1<<20,
 177                                                                1<<21,
 178                                                                1<<22,
 179                                                                1<<23,
 180                                                                1<<24,
 181                                                                1<<25,
 182                                                                1<<26,
 183                                                                1<<27,
 184                                                                1<<28,
 185                                                                1<<29,
 186                                                                1<<30};
 187 
 188     /**
 189      * A method to access an array of extended modifiers for additional buttons.
 190      * @since 1.7
 191      */
 192     private static int [] getButtonDownMasks(){
 193         return Arrays.copyOf(BUTTON_DOWN_MASK, BUTTON_DOWN_MASK.length);
 194     }
 195 
 196 
 197     /**
 198      * A method to obtain a mask for any existing mouse button.
 199      * The returned mask may be used for different purposes. Following are some of them:
 200      * <ul>
 201      * <li> {@link java.awt.Robot#mousePress(int) mousePress(buttons)} and
 202      *      {@link java.awt.Robot#mouseRelease(int) mouseRelease(buttons)}
 203      * <li> as a {@code modifiers} parameter when creating a new {@link MouseEvent} instance
 204      * <li> to check {@link MouseEvent#getModifiersEx() modifiersEx} of existing {@code MouseEvent}
 205      * </ul>
 206      * @param button is a number to represent a button starting from 1.
 207      * For example,
 208      * <pre>
 209      * int button = InputEvent.getMaskForButton(1);
 210      * </pre>


 220      *    <b>button </b>   <b>returned mask</b>
 221      *    {@link MouseEvent#BUTTON1 BUTTON1}  {@link MouseEvent#BUTTON1_DOWN_MASK BUTTON1_DOWN_MASK}
 222      *    {@link MouseEvent#BUTTON2 BUTTON2}  {@link MouseEvent#BUTTON2_DOWN_MASK BUTTON2_DOWN_MASK}
 223      *    {@link MouseEvent#BUTTON3 BUTTON3}  {@link MouseEvent#BUTTON3_DOWN_MASK BUTTON3_DOWN_MASK}
 224      * </PRE>
 225      * If a mouse has more than three enabled buttons then more values
 226      * are admissible (4, 5, etc.). There is no assigned constants for these extended buttons.
 227      * The button masks for the extra buttons returned by this method have no assigned names like the
 228      * first three button masks.
 229      * <p>
 230      * This method has the following implementation restriction.
 231      * It returns masks for a limited number of buttons only. The maximum number is
 232      * implementation dependent and may vary.
 233      * This limit is defined by the relevant number
 234      * of buttons that may hypothetically exist on the mouse but it is greater than the
 235      * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
 236      *
 237      * @return a mask for an existing mouse button.
 238      * @throws IllegalArgumentException if {@code button} is less than zero or greater than the number
 239      *         of button masks reserved for buttons
 240      * @since 1.7
 241      * @see java.awt.MouseInfo#getNumberOfButtons()
 242      * @see Toolkit#areExtraMouseButtonsEnabled()
 243      * @see MouseEvent#getModifiers()
 244      * @see MouseEvent#getModifiersEx()
 245      */
 246     public static int getMaskForButton(int button) {
 247         if (button <= 0 || button > BUTTON_DOWN_MASK.length) {
 248             throw new IllegalArgumentException("button doesn\'t exist " + button);
 249         }
 250         return BUTTON_DOWN_MASK[button - 1];
 251     }
 252 
 253     // the constant below MUST be updated if any extra modifier
 254     // bits are to be added!
 255     // in fact, it is undesirable to add modifier bits
 256     // to the same field as this may break applications
 257     // see bug# 5066958
 258     static final int FIRST_HIGH_BIT = 1 << 31;
 259 
 260     static final int JDK_1_3_MODIFIERS = SHIFT_DOWN_MASK - 1;