public class InputMap extends Object implements Serializable
InputMap提供输入事件之间的绑定(目前仅使用KeyStroke )和Object 。
InputMap通常与ActionMap一起使用,以确定按下键时执行的Action 。
一个InputMap可以有一个父类,可以搜索InputMap未定义的绑定。
和ActionMap如果你创建一个循环,例如:
InputMap am = new InputMap();
InputMap bm = new InputMap():
am.setParent(bm);
bm.setParent(am);
一些方法将导致抛出一个StackOverflowError。
| Constructor and Description |
|---|
InputMap()
创建一个没有父对象的
InputMap ,没有映射。
|
| Modifier and Type | Method and Description |
|---|---|
KeyStroke[] |
allKeys()
返回此
InputMap及其父级中定义的
KeyStroke的数组。
|
void |
clear()
从这个
InputMap删除所有的映射。
|
Object |
get(KeyStroke keyStroke)
返回
keyStroke的绑定,如果绑定不在本地定义,则发送父
InputMap 。
|
InputMap |
getParent()
得到这个
InputMap的父母。
|
KeyStroke[] |
keys()
返回
KeyStroke中绑定的
InputMap 。
|
void |
put(KeyStroke keyStroke, Object actionMapKey)
将
keyStroke的绑定添加到
actionMapKey 。
|
void |
remove(KeyStroke key)
从
InputMap删除
key的绑定。
|
void |
setParent(InputMap map)
设置这个
InputMap的父母。
|
int |
size()
返回
KeyStroke绑定的数量。
|
public void setParent(InputMap map)
InputMap的父母。
map - 这是一个
InputMap的父母
public InputMap getParent()
InputMap的父母。
InputMap映射为该父项,如果此
InputMap没有父级,则为null
public void put(KeyStroke keyStroke, Object actionMapKey)
keyStroke的绑定添加到actionMapKey 。
如果actionMapKey为空,则将删除keyStroke的当前绑定。
public void remove(KeyStroke key)
InputMap删除
key的绑定。
public void clear()
InputMap删除所有的映射。
public KeyStroke[] keys()
KeyStroke中绑定的
InputMap 。
public int size()
KeyStroke绑定的数量。
public KeyStroke[] allKeys()
InputMap及其父级中定义的KeyStroke的数组。
这与keys()的不同之处在于,该方法包括在父级中定义的键。
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.