黑马程序员技术交流社区

标题: 初学GUI的问题 [打印本页]

作者: 人言落日是天涯    时间: 2014-6-7 22:40
标题: 初学GUI的问题
问题在代码注释中。
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. class AwtDemo
  4. {
  5. public static void main(String[] args)
  6. {
  7. Frame f = new Frame();

  8. f.setSize(400,300);

  9. f.setLocation(300,200);

  10. f.setLayout(new FlowLayout());

  11. Button b = new Button("anniu");
  12. f.add(b);
  13. f.addWindowListener(new WindowAdapter()
  14. {
  15. public void windowClosing(WindowEvent e)
  16. {
  17. System.out.println("windowListener");
  18. // 如果写成这样:System.out.println("windowListener"+e.toString());会报错,变量e错误
  19. }
  20. });

  21. f.setVisible(true);
复制代码


作者: 496080891    时间: 2014-6-8 14:28
运行无错误提示啊

1.jpg (31.67 KB, 下载次数: 50)

1.jpg

作者: 人言落日是天涯    时间: 2014-6-8 16:09
496080891 发表于 2014-6-8 14:28
运行无错误提示啊

错误在注释中,现在我懂了,抽象类无法实例化对象




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2