//Program to implement mouse events
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Mouseevents extends Applet implements MouseListener,MouseMotionListener
{
/*<applet code=”Mouseevents” width=500 height=300></applet>*/
String msg=””;
int mousex=0,mousey=0;
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=0;
mousey=10;
msg=”mouse entered”;
repaint();
}
public void mouseExited(MouseEvent me)
{
mousex=0;
mousey=10;
msg=”mouse exited”;
repaint();
}
public void mousePressed(MouseEvent me)
{
mousex=me.getX();
mousey=me.getY();
msg=”down”;
repaint();
}
public void mouseReleased(MouseEvent me)
{
mousex=me.getX();
mousey=me.getY();
msg=”up”;
repaint();
}
public void mouseDragged(MouseEvent me)
{
mousex=me.getX();
mousey=me.getY();
msg=”*”;
showStatus(“Dragging mouse at “+mousex+” , “+mousey);
repaint();
}
public void mouseMoved(MouseEvent me)
{
showStatus(“mouse moving at “+me.getX()+” , “+me.getY());
}
public void paint(Graphics g)
{
g.drawString(msg,mousex,mousey);
}
}
Output:
Salemetsiz Be,
Best thing I have read in a while on this Write a Program for Handling Mouse events . There should be a standing ovation button. This is a great piece.
I am doing a program which will delete the duplicate match pair from the matching pair list between two string.It will print all the arrays except those duplicate pairs.
suppose ,from two given sequence we got the following matching pairs based on their positions
p[0]=(0,1)
p[1]=(0,5)
p[2]=(1,0)
p[3]=(1,2)
p[4]=(1,7)
p[5]=(2,4)
p[6]=(2,6)
p[7]=(3,3)
p[8]=(3,8)
p[9]=(4,0)
p[10]=(4,2)
now,i want to delete the pairs which has the same element,i.e.(0,1)&(1,0) are the pairs which contained the same elements.
I want to delete(1,0)& like that (4,2).
the final result should be printed all the matching pairs except (1,0)&(4,2).
I read multiple articles and watched many videos about how to use this tool – and was still confused! Your instructions were easy to understand and made the process simple.
Obrigado,
Irene Hynes
Your blog has piqued a lot of real interest. I can see why since you have done such a good job of making it interesting. I appreciate your efforts very much. handling equipment