Posted on 2012-07-17 23:45
eboy 阅读(132)
评论(0) 编辑 收藏 所属分类:
GUI
//JAVA GUI 鼠标单击演示
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class MouseKey {
public static void main(String[] args) {
Frame f = new Frame("鼠标单击事件演示");
f.setBounds(400, 400, 640, 480);
f.setLayout(new FlowLayout());
Button btn = new Button("关闭");
f.add(btn);
btn.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
System.exit(0);
}
});
f.setVisible(true);
}
}