标签:
第一次对监听器的使用
监听器:是一个监听器接口的实例,并且必须注册到源对象上
监听器实现监听器接口
创建监听器注册到源对象上面
注册方法:调用source.addActionListener()来注册
第一步(70行):创建EnlargeListener 类 实现 ActionListener接口
第二步(28行):new一个监听器 ,再注册到button1上
第三步(54行):创建enlarge方法 以被调用
第四步(74行):覆盖接口中的actionPerformed方法 一旦监听到该操作 执行下一句 调用enlarge方法
第五步(71行):为了让actionPerformed能访问enlarge方法 ,将该类定义成inner class
enlarge 和 shrink键是控制圆圈的放大和缩小
【JAVA语言程序设计基础篇】--事件驱动程序设计--了解监听器、注册以及处理事件
标签:
原文地址:http://blog.csdn.net/qq_24653023/article/details/52230365