import java.applet.*;
import java.awt.event.*;
import java.awt.*;
/*<applet code="MouseEvents" width=400 height=400>
</applet>*/
public class MouseEvents extends Applet implements MouseListener,MouseMotionListener
{
String msg="";
int mouseX=100,mouseY=100;
public void init()
{
addMouseListener(this);
addMouseMotionListener(this);
}
public void mouseClicked(MouseEvent me)
{
mouseX=0;
mouseY=10;
msg="Mouse clicked";
repaint();
}
public void mouseEntered(MouseEvent me)
{
mouseX=me.getX();
mouseY=me.getY();
msg="Mouse Entered";
repaint();
}
public void mouseExited(MouseEvent me)
{
mouseX=me.getX();
mouseY=me.getY();
msg="Mouse Exited";
repaint();
}
public void mousePressed(MouseEvent me)
{
mouseX=me.getX();
mouseY=me.getY();
msg="Mouse Pressed";
repaint();
}
public void start()
{
if(mouseX==100&& mouseY==100)
{
msg="You win";
}
repaint();
}
public void mouseReleased(MouseEvent me)
{
mouseX=me.getX();
mouseY=me.getY();
msg="Mouse Released";
repaint();
}
public void mouseMoved(MouseEvent me)
{
showStatus("Moving mouse at"+me.getX()+","+me.getY());
}
public void mouseDragged(MouseEvent me)
{
mouseX=me.getX();
mouseY=me.getY();
msg="***";
showStatus("Dragging mouse at"+me.getX()+","+me.getY());
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,mouseX,mouseY);
}
}