- import java.awt.event.*;
- import java.awt.Graphics;
- import java.applet.Applet;
- /*<applet code="MouseDemo.class" width="300" height="300"></applet>*/
- public class MouseDemo extends Applet implements MouseListener,MouseMotionListener
- {
- String msg="";
- int x=100,y=160;
- public void init()
- {
- addMouseListener(this);
- addMouseMotionListener(this);
- }
- public void mouseClicked(MouseEvent me)
- {
- x=0;
- y=10;
- msg="Mouse Clicked";
- repaint();
- }
- public void mousePressed(MouseEvent me)
- {
- msg="Down";
- x=me.getX();
- y=me.getY();
- repaint();
- }
- public void mouseReleased(MouseEvent me)
- {
- msg="Mouse Released";
- x=me.getX();
- y=me.getY();
- repaint();
- }
- public void mouseEntered(MouseEvent me)
- {
- msg="Mouse Entered";
- repaint();
- }
- public void mouseExited(MouseEvent me)
- {
- msg="Mouse Exited";
- repaint();
- }
- public void mouseDragged(MouseEvent me)
- {
- x=me.getX();
- y=me.getY();
- msg="*";
- showStatus("Mouse Dragging at:="+me.getX()+" "+me.getY());
- }
- public void mouseMoved(MouseEvent me)
- {
- showStatus("Mouse Moving at:="+me.getX()+" "+me.getY());
- }
- public void paint(Graphics g)
- {
- g.drawString(msg,x,y);
- }
- }
[text] aa
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: