首页 > 其他 > 详细

e643. 以匿名类处理事件

时间:2018-09-02 23:05:29      阅读:194      评论:0      收藏:0      [点我收藏+]

If an event handler is specific to a component (that is, not shared by other components), there is no need to declare a class to handle the event. The event handler can be implemented using an anonymous inner class. This example demonstrates an anonymous inner class to handle key events for a component.

    
component.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent evt) {
        }
    });

 

Related Examples

e643. 以匿名类处理事件

原文:https://www.cnblogs.com/borter/p/9575401.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!