MouseTracker in Java Program
MouseTracker in Java Program
import java.awt.event.*;
import javax.Swing.*;
public class MouseTracker extends JFrame implements MouseListener,MouseMotionListener
{
private JLabel Statusbar;
public MouseTracker()
{
super("MouseTracker");
statusbar=new JLabek();
getcontentPane().add(StatusbarBorderLayout.SOUTH);
addMouseListener(this);
addMouseMotionListener(this);
setSize(200,200);
setVisible(true);
}
public void mouseClicked(MouseEvent event)
{
Statusbar.setText("MouseCLicked@x="+event.getX()+"y="+event.getY());
}
public void mousePressed(MouseEvent event)
{
Statusbar.setText("MousePressed@x="+event.getx()+"y="+event.gety());
}
public void mouseReleased(MouseEvent event)
{
Statusbar.setText("MouseReleased@x="+event.getx()+"y="+event.gety());
}
public void mouseEntered(MouseEvent event)
{
Statusbar.setText("MouseEntered@x="+event.getx()+"y="+event.gety());
}
public void mouseExited(MouseEvent event)
{
Statusbar.setText("MouseExited@x="+event.getx()+"y="+event.gety());
}
public void mouseDragged(MouseEvent event)
{
Statusbar.setText("MouseDragged@x="+event.getx()+"y="+event.gety());
}
public void mouseMoved(MouseEvent event)
{
Statusbar.setText("MouseMoved@x="+event.getx()+"y="+event.gety());
}
public Static void main(String args[])
{
MouseTracker application=new MouseTracker();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
0 coment�rios:
Post a Comment