zoukankan      html  css  js  c++  java
  • 事件驱动程序设计

    一、动作事件(ActionEvent)

    ActionListener

    public void actionPerformed(ActionEvent e)

    二、窗口事件(WindowEvent)

    WindowListener

    Window类的任何一个子类都可能触发下面的窗口事件:

    打开窗口、正在关闭窗口、关闭窗口、激活窗口、变成非活动窗口、最小化窗口和还原窗口
    (windowOpened,windowClosing,windowClosed,windowActivated,windowDeactivated,windowIconified,windowDeiconified)。

    三、鼠标事件(MouseEvent)

    当在一个组件上按下、释放、点击、移动或拖动鼠标时就会产生鼠标事件。

    MouseEvent类继承InputEvent类,所以可以在MouseEvent对象上使用InputEvent类中定义的方法。

    Java提供了两个处理鼠标事件的监听器接口MouseListener和MouseMotionListener。

    实现MouseListener接口可以监听如鼠标的按下、释放、输入、退出或点击的动作,然后实现MouseMotionListener
    接口以监听如拖动鼠标或移动鼠标的动作。 mouseDraggedmouseMoved

    四、按键事件(KeyEvent)

    KeyListener

    按下、释放或敲击一个键。

    KeyPressed、KeyReleased、KeyTyped处理器来处理KeyEvent。

    getKeyCode()返回常量值(VK_UP、VK_DOWN等等)、getkeyChar()返回输入的字符。

    五、Timer能够触发actionEvent

    Timer(delay:int,listener:actionListener);创建一个带特定的毫秒延时和ActionListener的Timer对象。

    addActionListener();

    start();

    end();

    setDelay(delay:int)

  • 相关阅读:
    南邮NOJ整除的尾数
    【HDOJ】2844 Coins
    【HDOJ】2546 饭卡
    【HDOJ】1031 Design T-Shirt
    【HDOJ】1983 Kaitou Kid
    【HDOJ】2612 Find a way
    【原创】如何构建MIPS交叉编译工具链
    【HDOJ】1239 Calling Extraterrestrial Intelligence Again
    【Python Network】使用DOM生成XML
    【HDOJ】2602 Bone Collector
  • 原文地址:https://www.cnblogs.com/mydesky2012/p/4543560.html
Copyright © 2011-2022 走看看