日期:2014-05-20 浏览次数:20703 次
import java.awt.BorderLayout;
import java.awt.TextField;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
* http://bbs.csdn.net/topics/390340915
*
* @author ceclinux
*
*/
public class MouseExitExample extends JFrame {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new MouseExitExample();
}
public MouseExitExample() {
setVisible(true);
setSize(300,300);
JButton jb=new JButton("dfsafs");
jb.setSize(200,200);
add(jb,BorderLayout.EAST);
final JTextField tf = new JTextField();
tf.setSize(200,200);
tf.addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
System.out.println("a");
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
});
add(tf);
}
}