Search your topic here

Applet mouse event handling

APPLET MOUSE EVENT:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class MouseApplet extends Applet implements MouseMotionListener{
        public void init(){
                    addMouseMotionListener(this);
                    setBackground(Color.WHITE);
                    }
                   
                    public void mouseDragged(MouseEvent me){
                    Graphics g=getGraphics();
                    g.setColor(Color.black);
                    g.drawOval(me.getX(),me.getY(), 10, 10);
                    }
                    public void mouseMoved(MouseEvent me){}
                   
}
OUTPUT:

LEAVE A REPLY