package Window;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
public class AwtDemo {
public static void main(String[] args) {
Frame frame=new Frame("my dreea");
frame.setSize(300,300);
frame.setLayout(new FlowLayout());
frame.setBounds(300, 200, 300, 300);
Button butten=new Button("我的按钮");
Button butten1=new Button("我的按钮");
Button butten2=new Button("我的按钮");
Button butten3=new Button("我的按钮");
frame.add(butten);
frame.add(butten1);
frame.add(butten2);
frame.add(butten3);
butten.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.out.println("按钮关闭窗口");
System.exit(0);
}
});
butten1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.out.println("按钮关闭窗口");
System.exit(0);
}
});
butten2.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.out.println("关闭窗口");
System.exit(0);
}
});
butten3.addMouseListener(new MouseAdapter(){//红色部分怎么会报错呢????搞不懂
public void mouseEntered(MouseEvent e) {
System.out.println("滑过窗口");
}
});
//frame.addWindowListener(new Listen());
frame.setVisible(true);
}
}
|
|