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

Print this page




 741             throw new IllegalArgumentException("Invalid button value :" + button);
 742         }
 743         if (button > BUTTON3) {
 744             if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
 745                 throw new IllegalArgumentException("Extra mouse events are disabled " + button);
 746             } else {
 747                 if (button > cachedNumberOfButtons) {
 748                     throw new IllegalArgumentException("Nonexistent button " + button);
 749                 }
 750             }
 751             // XToolkit: extra buttons are not reporting about their state correctly.
 752             // Being pressed they report the state=0 both on the press and on the release.
 753             // For 1-3 buttons the state value equals zero on press and non-zero on release.
 754             // Other modifiers like Shift, ALT etc seem report well with extra buttons.
 755             // The problem reveals as follows: one button is pressed and then another button is pressed and released.
 756             // So, the getModifiersEx() would not be zero due to a first button and we will skip this modifier.
 757             // This may have to be moved into the peer code instead if possible.
 758 
 759             if (getModifiersEx() != 0) { //There is at least one more button in a pressed state.
 760                 if (id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED){
 761                     System.out.println("MEvent. CASE!");
 762                     shouldExcludeButtonFromExtModifiers = true;
 763                 }
 764             }
 765         }
 766 
 767         this.button = button;
 768 
 769         if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
 770             setNewModifiers();
 771         } else if ((getModifiers() == 0) &&
 772                    (getModifiersEx() != 0 || button != NOBUTTON) &&
 773                    (button <= BUTTON3))
 774         {
 775             setOldModifiers();
 776         }
 777     }
 778 
 779     /**
 780      * Returns the horizontal x position of the event relative to the
 781      * source component.




 741             throw new IllegalArgumentException("Invalid button value :" + button);
 742         }
 743         if (button > BUTTON3) {
 744             if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
 745                 throw new IllegalArgumentException("Extra mouse events are disabled " + button);
 746             } else {
 747                 if (button > cachedNumberOfButtons) {
 748                     throw new IllegalArgumentException("Nonexistent button " + button);
 749                 }
 750             }
 751             // XToolkit: extra buttons are not reporting about their state correctly.
 752             // Being pressed they report the state=0 both on the press and on the release.
 753             // For 1-3 buttons the state value equals zero on press and non-zero on release.
 754             // Other modifiers like Shift, ALT etc seem report well with extra buttons.
 755             // The problem reveals as follows: one button is pressed and then another button is pressed and released.
 756             // So, the getModifiersEx() would not be zero due to a first button and we will skip this modifier.
 757             // This may have to be moved into the peer code instead if possible.
 758 
 759             if (getModifiersEx() != 0) { //There is at least one more button in a pressed state.
 760                 if (id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED){

 761                     shouldExcludeButtonFromExtModifiers = true;
 762                 }
 763             }
 764         }
 765 
 766         this.button = button;
 767 
 768         if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
 769             setNewModifiers();
 770         } else if ((getModifiers() == 0) &&
 771                    (getModifiersEx() != 0 || button != NOBUTTON) &&
 772                    (button <= BUTTON3))
 773         {
 774             setOldModifiers();
 775         }
 776     }
 777 
 778     /**
 779      * Returns the horizontal x position of the event relative to the
 780      * source component.