KickJava   Java API By Example, From Geeks To Geeks.

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

java.awt.event
Interface MouseMotionListener

All Superinterfaces:
EventListener
All Known Subinterfaces:
MouseInputListener
All Known Implementing Classes:
AWTEventMulticaster, BasicButtonListener, BasicComboPopup.InvocationMouseMotionHandler, BasicComboPopup.ListMouseMotionHandler, BasicDesktopIconUI.MouseInputHandler, BasicInternalFrameUI.BorderListener, BasicInternalFrameUI.GlassPaneDispatcher, BasicListUI.MouseInputHandler, BasicMenuItemUI.MouseInputHandler, BasicMenuUI.MouseInputHandler, BasicScrollBarUI.TrackListener, BasicSliderUI.TrackListener, BasicSplitPaneDivider.MouseHandler, BasicTableHeaderUI.MouseInputHandler, BasicTableUI.MouseInputHandler, BasicTextUI.BasicCaret, BasicToolBarUI.DockingListener, BasicTreeUI.MouseHandler, BasicTreeUI.MouseInputHandler, DefaultCaret, HTMLEditorKit.LinkController, MetalToolBarUI.MetalDockingListener, MouseDragGestureRecognizer, MouseInputAdapter, MouseMotionAdapter, ToolTipManager
See Also:
Top Examples, Source Code, MouseEvent

void mouseDragged(MouseEvent e)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[83]Make our hello movable with the mouse
By Anonymous on 2002/10/14 18:53:23  Rate
//make our hello movable with the mouse 
  
  
 import java.applet.Applet; 
 import java.awt.*; 
 import java.awt.event.*; 
  
  
 public class HelloWeb2  
 extends Applet  
 implements MouseMotionListener  {  
  
  
 int messageX = 125, messageY = 95;   
 String theMessage; 
  
  
 // start the process 
 public void init (  )   {  
   // get a parameter from the applet tag 
   theMessage = getParameter ( "message" ) ;         
   // register the mouseDragged and mouseMoved event handlers.  
   addMouseMotionListener ( this ) ; 
  }  
  
  
 // paint the message; overrides Applet.paint, which draws a blank.  
 public void paint (  Graphics graphics  )   {  
   graphics.drawString (  theMessage, messageX, messageY  ) ; 
  }  
  
  
 // move the message wherever we drag the mouse with button down 
 public void mouseDragged (  MouseEvent e  )   {  
   messageX = e.getX (  ) ; messageY = e.getY (  ) ;  
   // note: YOU call repaint, repaint calls your paint! 
   repaint (  ) ; 
  }  
  
  
 // do nothing so far if we simply moved the mouse with button up 
 public void mouseMoved (  MouseEvent e  )   {   }  
  
  
  } 


void mouseMoved(MouseEvent e)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags