import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class demo
implements MouseListener
{
Container cp;
TextField t;
JFrame f;
JLabel la;
public demo()
{
f=new JFrame();
t=new TextField(100);
cp=f.getContentPane();
cp.setLayout(new BorderLayout());
la=new JLabel("请输入数据");
cp.add(la,BorderLayout.CENTER);
cp.add(t,BorderLayout.EAST);
la.addMouseListener(this);
f.pack();
f.show();
}
public void mouseClicked(MouseEvent ev){
t.setText(la.getText()+"mouseClicked");
}
//响应压下鼠标
public void mousePressed(MouseEvent ev){
t.setText(la.getText()+"mousePressed");
}
//响应松开鼠标
public void mouseReleased(MouseEvent ev){
t.setText(la.getText()+"mouseReleased");
}
//响应鼠标进入
public void mouseEntered(MouseEvent ev){
t.setText(la.getText()+"mouseEntered");
}
//响应鼠标退出
public void mouseExited(MouseEvent ev){
t.setText(la.getText()+"mouseExited");
}
public static void main(String []args)
{
new demo();
}
}