AWTDeviceFactory.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:NK-VirtualGlobe 作者:
/**
 * Return the array of DeviceManagers that are available per the
 * constructor parameters. The InputDevices instantiated will be
 * initialized with the AWT ui toolkit event listeners.
 *
 * @return the array of DeviceManagers. If no DeviceManagers are
 * available, an empty (size 0) array is returned.
 */
public DeviceManager[] getDeviceManagers( ) {
    List managerList = createDevices( );
    DeviceManager[] manager =
        (DeviceManager[])managerList.toArray( new DeviceManager[managerList.size( )] );
    Component cmp = (Component)canvas;
    for( int i = 0; i < manager.length; i++ ) {
        InputDevice[] device = manager[i].getDevices( );
        for( int j = 0; j < device.length; j++ ) {
            InputDevice dev = device[j];
            if( dev instanceof MouseListener ) {
                cmp.addMouseListener( (MouseListener)dev );
            }
            if( dev instanceof MouseMotionListener ) {
                cmp.addMouseMotionListener( (MouseMotionListener)dev );
            }
            if( dev instanceof MouseWheelListener ) {
                cmp.addMouseWheelListener( (MouseWheelListener)dev );
            }
            if( dev instanceof KeyListener ) {
                cmp.addKeyListener( (KeyListener)dev );
            }
        }
    }
    return( manager );
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号