KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > awt > event > InputEvent

java.awt.event
Class InputEvent

java.lang.Object
  extended by java.util.EventObject
      extended by java.awt.AWTEvent
          extended by java.awt.event.ComponentEvent
              extended by java.awt.event.InputEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
KeyEvent, MouseEvent
See Also:
Top Examples, Source Code, KeyAdapter, MouseAdapter, MouseMotionAdapter

public static final int ALT_DOWN_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ALT_GRAPH_DOWN_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ALT_GRAPH_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ALT_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[53]Detect 3 mouse buttons click
By Anonymous on 2002/10/07 17:01:27  Rate
/** Single button mouses can simulate a button two by holding  
   * down the ALT key. Button three by holding down the META key. 
   **/
 
  
  
  
  
 import java.applet.*;  
 import java.awt.*;  
 import java.awt.event.*;  
  
  
 public class exmouse extends Applet  {   
   TextArea textArea;  
   String newline;  
  
  
   public void init (  )   {   
  
  
     setLayout ( new BorderLayout (  )   ) ;  
  
  
     Canvas c = new Canvas (  ) ;  
     add ( c, "North" ) ;  
     c.setSize ( 300,150 ) ;  
     c.setBackground ( Color.red ) ;  
  
  
     textArea = new TextArea (  ) ;  
     textArea.setEditable ( false ) ;  
     add ( textArea, "South" ) ;  
    
  
  
     c.addMouseListener (  new MouseAdapter (  )   {   
       public void mouseClicked ( MouseEvent e )   {   
         if  (  ( e.getModifiers (  )  & InputEvent.BUTTON1_MASK )  != 0 )   
                           saySomething (  "button1 pressed", e ) ;  
         if  (  ( e.getModifiers (  )  & InputEvent.BUTTON2_MASK )  != 0 )   
                           saySomething (  "button2 pressed",e  ) ;  
         if  (  ( e.getModifiers (  )  & InputEvent.BUTTON3_MASK )  != 0 )   
                           saySomething (  "button3 pressed",e  ) ;  
  
  
         if  (  ( e.getModifiers (  )  & InputEvent.ALT_MASK )  != 0 )   
                           saySomething (  "alt pressed" ,e ) ;  
         if  (  ( e.getModifiers (  )  & InputEvent.META_MASK )  != 0 )   
                           saySomething (  "meta pressed",e  ) ;  
        }   
      }  // end anon class  
      ) ; // end method call  
  
  
    }   
   void saySomething ( String eventDescription,MouseEvent e )   {   
     textArea.append ( eventDescription + " detected on " + e.getComponent (  ) .getClass (  ) .getName (  )   
                         + "." + "\n" ) ;  
    }   
  }   
  
  
  
 


public static final int BUTTON1_DOWN_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int BUTTON1_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int BUTTON2_DOWN_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int BUTTON2_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int BUTTON3_DOWN_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int BUTTON3_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void consume()
See Also:
AWTEvent
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CTRL_DOWN_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CTRL_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getModifiers()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[52]Detect right mouse button
By Anonymous on 2002/10/07 16:59:02  Rate
/** 
   * The right mouse buttons on a 2 and 3 button mouse  
   * can be detected with the getModifiers (  )  method  
   * of the event class: 
   * 
   * Similar buttons can be identified with 
   * 
   * BUTTON1_MASK 
   * BUTTON2_MASK 
   * ALT_MASK 
   * META_MASK 
   **/
 
  
  
 public void mouseClicked ( MouseEvent e )  {  
  if  (   
   e.getModifiers (  )  & InputEvent.BUTTON3_MASK )  != 0 )  
     doSomething (  ) ; 
   ...  
  
  
  
 


public int getModifiersEx()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static String getModifiersExText(int modifiers)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public long getWhen()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isAltDown()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isAltGraphDown()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isConsumed()
See Also:
consume(), AWTEvent
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isControlDown()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isMetaDown()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isShiftDown()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int META_DOWN_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int META_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[51]Detect 3rd mouse button
By Anonymous on 2002/10/07 16:54:44  Rate
import java.awt.event.*; 
 class Main  {  
     boolean isMetaDown ( InputEvent evt )   {  
         return  ( evt.getModifiers (  )  & InputEvent.META_MASK )  != 0; 
      }  
  } 


public static final int SHIFT_DOWN_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int SHIFT_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags