Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

please help me with actionlistener

Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
following is the java source file code that compiles allright
import java.awt.event.*;
import java.applet.Applet;
import java.awt.*;

public class movemouse extends Applet implements MouseMotionListener
int a,b,c,d;
public void mouseMoved(MouseEvent evt)

public void mouseDragged(MouseEvent evt)


public void paint(Graphics g)

public void update(Graphics g)

but when i run this applet in appletviewer and on appletviewer
when i move mouse i should see red lines on applet when mouse move and blue when mouse dargged.but when i run this applet,i move mouse ,i can not see any lines on applet.i have done this type of applet with old methods like
public boolean mouseMove (Event e,int x,int y) {}
but this methods are deprecated so i have to use above code part methods .how can i do this please help me.more tips about events and listeners will be appriciated.
thank you very much.

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure but i think you just have defined methods for handling the events, that is you have defined what shoud happen and also when, but you forgot to tell on which component this shoud happen. That is, you should register a listener for the applet itself in the init() method. So that when the mouse moves over the applet, your method should then envoked.


public void init() {
A feeble attempt to tell you about our stuff that makes us money
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic