看了半个小时没看出这两个代码 有什么不同,但是编译运行的结果不一样。泪奔。求大神告诉我真像!
(代码来自于基础课第22天05GUI(窗体事件))
第一个:
- import java.awt.*;
- import java.awt.event.*;
- class AwtDemo
- {
- public static void main(String[] args)
- {
- Frame f =new Frame("my awt");
- f.setSize(500,400);
- f.setLocation(300,200);
- f.setLayout(new FlowLayout());
- Button b =new Button("我是按钮");
- f.add(b);
- f.addWindowListener(new WindowAdapter()
- {
- public void WindowClosing(WindowEvent e)
- {
- System.out.println("我关");
- System.exit(0);
- }
- public void WindowActivated(WindowEvent e)
- {
- System.out.println("我活了。");
- }
- public void WindowOpened(WindowEvent e)
- {
- System.out.println("我被打开了,hahahhahah");
- }
- });
- f.setVisible(true);
- }
- }
复制代码
第二个:
- import java.awt.*;
- import java.awt.event.*;
- class AwtDemo
- {
- public static void main(String[] args)
- {
- Frame f = new Frame("my awt");
- f.setSize(500,400);
- f.setLocation(300,200);
- f.setLayout(new FlowLayout());
- Button b = new Button("我是一个按钮");
- f.add(b);
- f.addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e)
- {
- System.out.println("我关");
- System.exit(0);
- }
- public void windowActivated(WindowEvent e)
- {
- System.out.println("我活了。");
- }
- public void windowOpened(WindowEvent e)
- {
- System.out.println("我被打开了,hahahhahah");
- }
- });
- f.setVisible(true);
- }
- }
复制代码
|