Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Java AWT Code Examples

Demonstrating mouse Event constants

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Demonstrating mouse Event constants import java.applet.Applet; import java.awt.*; public class MouseEvents extends Applet { private List eventList; public void init() { eventList = new List( 6, false ); add( eventList ); } public boolean handleEvent( Event e ) { // determine which mouse event occured switch ( e.id ) { case Event.MOUSE_UP: eventList.addItem( "Mouse up" ); return true; case Event.MOUSE_DOWN: eventList.addItem( "Mouse down" ); return true; case Event.MOUSE_MOVE: showStatus( "Mouse move" ); return true; case Event.MOUSE_ENTER: eventList.addItem( "Mouse enter"); return true; case Event.MOUSE_EXIT: eventList.addItem( "Mouse exit" ); return true; case Event.MOUSE_DRAG: showStatus( "Mouse drag" ); return true; } // not one of our mouse events showStatus( "Not one of the mouse events!" ); return true; // done processing } }