java.lang.Object
java.util.EventObject
java.awt.AWTEvent
java.awt.event.ComponentEvent
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
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
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