public abstract class KeyAdapter extends Object implements KeyListener
扩展这个类来创建一个KeyEvent听众和覆盖感兴趣的事件的方法。(如果你实施KeyListener接口,你必须定义所有的方法在这。这个抽象类定义了他们所有的空方法,所以你只能定义你关心的事件的方法。)
创建一个使用扩展类的听众对象然后登记与组件使用组件的addKeyListener方法。当一个键被按下,释放,或打印,在监听对象相关的方法被调用时,与KeyEvent传递给它。
KeyEvent,
KeyListener,
Tutorial: Writing a Key Listener
| Constructor and Description |
|---|
KeyAdapter() |
| Modifier and Type | Method and Description |
|---|---|
void |
keyPressed(KeyEvent e)
当一个键被按下时调用。
|
void |
keyReleased(KeyEvent e)
当一个键被释放时调用。
|
void |
keyTyped(KeyEvent e)
当一个键被类型化时调用。
|
public void keyTyped(KeyEvent e)
keyTyped 接口
KeyListener
public void keyPressed(KeyEvent e)
keyPressed 接口
KeyListener
public void keyReleased(KeyEvent e)
keyReleased 接口
KeyListener
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.