e643. handling events with an anonymous class.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 8 行

TXT
8
字号
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) {
        }
    });

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?