码迷,mamicode.com
首页 > 其他好文 > 详细

e643. 以匿名类处理事件

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

标签:this   dem   listener   example   cells   can   style   ali   The   

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. 以匿名类处理事件

标签:this   dem   listener   example   cells   can   style   ali   The   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!