看了JDK文档
看不懂
麻烦通俗地解释一下吧!

另外
在keyEvent中定义了虚拟键码
如keyEvent.VK_O
请问他和inputEvent中的修饰符常量有什么区别?

谢谢

解决方案 »

  1.   

    A KeyStroke represents a key action on the keyboard, or equivalent input device. KeyStrokes can correspond to only a press or release of a particular key, just as KEY_PRESSED and KEY_RELEASED KeyEvents do; alternately, they can correspond to typing a specific Java character, just as KEY_TYPED KeyEvents do. In all cases, KeyStrokes can specify modifiers (alt, shift, control, meta, altGraph, or a combination thereof) which must be present during the action for an exact match. KeyStrokes are used to define high-level (semantic) action events. Instead of trapping every keystroke and throwing away the ones you are not interested in, those keystrokes you care about automatically initiate actions on the Components with which they are registered. KeyStrokes are immutable, and are intended to be unique. Client code cannot create a KeyStroke; a variant of getKeyStroke must be used instead. These factory methods allow the KeyStroke implementation to cache and share instances efficiently. KeyStroke从字面意义上理解就是按键敲击,所以他其中也提到了等同的输入设备,并不局限于键盘,它所代表的是一次按键动作。
    KeyStroke能符合这三种事件 KEY_PRESSED,KEY_RELEASED,KEY_TYPED。也能指定modifiers
    KeyStroke用于高级动作事件,语义的。
    KeyStroke是不可变的,也被设计成是唯一的(单例),通过工厂方法来让KeyStroke实现缓存并有效在客户端代码中共享实例。
      

  2.   

    InputEvent是这样定义的 
    The root event class for all component-level input events.
    它其中定义的静态常量都是Mask型KeyEvent是其子类,定义的都是虚拟键码,几乎没什么概念冲突啊
    不知道有没有回答到点上
      

  3.   

    InputEvent 输入事件,这我知道,但他具体是指哪些动作
    Mask是掩码的意思吧,什么叫掩码呢?不好意思,真的很难弄懂
      

  4.   

    要看具体,看他的一些应用方法不就清楚了
    它是一个抽象类,基础的概念,定义了输入事件一些共有的属性和动作
    比如isAltDown就是判断Alt Modifier是否被按下The root event class for all component-level input events. Input events are delivered to listeners before they are processed normally by the source where they originated. This allows listeners and component subclasses to "consume" the event so that the source will not process them in their default manner. For example, consuming mousePressed events on a Button component will prevent the Button from being activated. 称之为root event
    输入事件在产生它们的源组件能处理它们之前就被传送到了监听器,
    这就允许了监听者和组件子类们“消费”事件所以源不能以默认的方式处理它们
    例如在按钮上消费鼠标按下事件就会阻止按钮被激活
    In computer science, a mask is data that is used for bitwise operations.Using a mask, multiple bits in a byte, nibble, word (etc.) can be set either on, off or inverted from on to off (or vice versa) in a single bitwise operation.掩码总而言之就是用来进行位操作的数据