当前位置: 首页>>代码示例>>Java>>正文


Java MouseMotionListener类代码示例

本文整理汇总了Java中java.awt.event.MouseMotionListener的典型用法代码示例。如果您正苦于以下问题:Java MouseMotionListener类的具体用法?Java MouseMotionListener怎么用?Java MouseMotionListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MouseMotionListener类属于java.awt.event包,在下文中一共展示了MouseMotionListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
public void init() {
    if (script == null) {
        throw new RuntimeException("Script is null");
    }
    if (script instanceof MouseListener) {
        addMouseListener((MouseListener) script);
    }
    if (script instanceof MouseMotionListener) {
        addMouseMotionListener((MouseMotionListener) script);
    }
    if (script instanceof MessageListener) {
        addMessageListener((MessageListener) script);
    }
    if (script instanceof Paintable) {
        Context.getInstance().addPaintable((Paintable) script);
    }
    if (script instanceof GameActionListener) {
        addActionListener((GameActionListener) script);
    }
}
 
开发者ID:Parabot,项目名称:Parabot-317-API-Minified-PkHonor,代码行数:21,代码来源:ScriptEngine.java

示例2: addCurrentLineHighlightListeners

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Adds listeners that listen for changes to the current line, so we can
 * update our "current line highlight."  This is needed only because of an
 * apparent difference between the JRE 1.4.2 and 1.5.0 (needed on 1.4.2,
 * not needed on 1.5.0).
 */
private void addCurrentLineHighlightListeners() {
	boolean add = true;
	MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
	for (int i=0; i<mouseMotionListeners.length; i++) {
		if (mouseMotionListeners[i]==mouseListener) {
			add = false;
			break;
		}
	}
	if (add) {
		//System.err.println("Adding mouse motion listener!");
		addMouseMotionListener(mouseListener);
	}
	MouseListener[] mouseListeners = getMouseListeners();
	for (int i=0; i<mouseListeners.length; i++) {
		if (mouseListeners[i]==mouseListener) {
			add = false;
			break;
		}
	}
	if (add) {
		//System.err.println("Adding mouse listener!");
		addMouseListener(mouseListener);
	}
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:32,代码来源:RTextAreaBase.java

示例3: containsInGameComponents

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Checks if this {@code Canvas} contains any in game components.
 *
 * @return {@code true} if there is any in game components.
 */
public boolean containsInGameComponents() {
    KeyListener[] keyListeners = getKeyListeners();
    if (keyListeners.length > 0) {
        return true;
    }

    MouseListener[] mouseListeners = getMouseListeners();
    if (mouseListeners.length > 0) {
        return true;
    }

    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    if (mouseMotionListeners.length > 0) {
        return true;
    }

    return false;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:24,代码来源:Canvas.java

示例4: removeInGameComponents

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Removes components that is only used when in game.
 */
public void removeInGameComponents() {
    // remove listeners, they will be added when launching the new game...
    KeyListener[] keyListeners = getKeyListeners();
    for (KeyListener keyListener : keyListeners) {
        removeKeyListener(keyListener);
    }

    MouseListener[] mouseListeners = getMouseListeners();
    for (MouseListener mouseListener : mouseListeners) {
        removeMouseListener(mouseListener);
    }

    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (MouseMotionListener mouseMotionListener : mouseMotionListeners) {
        removeMouseMotionListener(mouseMotionListener);
    }

    for (Component c : getComponents()) {
        removeFromCanvas(c);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:25,代码来源:Canvas.java

示例5: InGameMenuBar

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Creates a new {@code FreeColMenuBar}. This menu bar will include
 * all of the submenus and items.
 *
 * @param freeColClient The main controller.
 * @param listener An optional mouse motion listener.
 */
public InGameMenuBar(FreeColClient freeColClient, MouseMotionListener listener) {
    // FIXME: FreeColClient should not have to be passed in to
    // this class.  This is only a menu bar, it doesn't need a
    // reference to the main controller.  The only reason it has
    // one now is because DebugMenu needs it.  And DebugMenu needs
    // it because it is using inner classes for ActionListeners
    // and those inner classes use the reference.  If those inner
    // classes were in seperate classes, when they were created,
    // they could use the FreeColClient reference of the
    // ActionManger.  So DebugMenu needs to be refactored to remove
    // inner classes so that this MenuBar can lose its unnecessary
    // reference to the main controller.  See FreeColMenuTest.
    //
    // Okay, I lied.. the update() and paintComponent() methods in
    // this MenuBar use freeColClient, too. But so what.  Move
    // those to another class too. :)
    super(freeColClient);

    // Add a mouse listener so that autoscrolling can happen in
    // this menubar
    this.addMouseMotionListener(listener);
    
    reset();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:32,代码来源:InGameMenuBar.java

示例6: addListener

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Adds an event listener to the Panel.
 *
 * @param eventListener
 *        The event listener.
 *
 * @throws IllegalArgumentException
 *        If the event listener isn't supported by this function.
 */
public void addListener(final EventListener eventListener) {
    if (eventListener instanceof KeyListener) {
        this.addKeyListener((KeyListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseListener) {
        this.addMouseListener((MouseListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseMotionListener) {
        this.addMouseMotionListener((MouseMotionListener) eventListener);
        return;
    }

    throw new IllegalArgumentException("The " + eventListener.getClass().getSimpleName() + " is not supported.");
}
 
开发者ID:Valkryst,项目名称:VTerminal,代码行数:28,代码来源:Panel.java

示例7: removeListener

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Removes an event listener from the Panel.
 *
 * @param eventListener
 *        The event listener.
 *
 * @throws IllegalArgumentException
 *        If the event listener isn't supported by this function.
 */
public void removeListener(final EventListener eventListener) {
    if (eventListener instanceof KeyListener) {
        this.removeKeyListener((KeyListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseListener) {
        this.removeMouseListener((MouseListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseMotionListener) {
        this.removeMouseMotionListener((MouseMotionListener) eventListener);
        return;
    }

    throw new IllegalArgumentException("The " + eventListener.getClass().getSimpleName() + " is not supported.");
}
 
开发者ID:Valkryst,项目名称:VTerminal,代码行数:28,代码来源:Panel.java

示例8: init

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
public void init() {
        if (script == null) {
            throw new RuntimeException("Script is null");
        }
        if (script instanceof MouseListener) {
            addMouseListener((MouseListener) script);
        }
        if (script instanceof MouseMotionListener) {
            addMouseMotionListener((MouseMotionListener) script);
        }
//        if (script instanceof MessageListener) {
//            addMessageListener((MessageListener) script);
//        }
        if (script instanceof Paintable) {
            Context.getInstance().addPaintable((Paintable) script);
        }
//        if (script instanceof GameActionListener) {
//            addActionListener((GameActionListener) script);
//        }
    }
 
开发者ID:Parabot,项目名称:Parabot-317-API-Minified-OS-Scape,代码行数:21,代码来源:ScriptEngine.java

示例9: removeListener

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
public void removeListener() {
    for (MouseListener ml : com.getMouseListeners()) {
        com.removeMouseListener(ml);
    }
    for (MouseMotionListener mml : com.getMouseMotionListeners()) {
        com.removeMouseMotionListener(mml);
    }
    for (KeyListener kl : com.getKeyListeners()) {
        com.removeKeyListener(kl);
    }
    reset();
    com.repaint();
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:14,代码来源:SelectionManager.java

示例10: setMouseAndKeyListeners

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Sets up mouse and key listeners
 */
protected void setMouseAndKeyListeners( MouseInputListener mouseHandler, KeyListener keyAdapter ) {
    // Clear the old handlers
    MouseListener[] mouseListeners = this.getMouseListeners();
    for ( int i = 0; i < mouseListeners.length; i++ ) {
        MouseListener mouseListener = mouseListeners[i];
        this.removeMouseListener( mouseListener );
    }
    MouseMotionListener[] mouseMostionListeners = this.getMouseMotionListeners();
    for ( int i = 0; i < mouseMostionListeners.length; i++ ) {
        MouseMotionListener mouseMostionListener = mouseMostionListeners[i];
        this.removeMouseMotionListener( mouseMostionListener );
    }
    KeyListener[] keyListeners = this.getKeyListeners();
    for ( int i = 0; i < keyListeners.length; i++ ) {
        KeyListener keyListener = keyListeners[i];
        this.removeKeyListener( keyListener );
    }

    // Add the new handlers
    this.addMouseListener( mouseHandler );
    this.addMouseMotionListener( getGraphic().getMouseHandler() );
    this.addKeyListener( keyAdapter );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:ApparatusPanel.java

示例11: setMovable

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Set whether the coordinate system is movable with the mouse, i.e.
 * the scope of the system changes as the the mouse is clicked, held
 * and dragged over the system.
 * 
 * @param movable
 *        If true, move is possible.
 */
public void setMovable(boolean movable) {
    if (this.movable && movable) return;
    if (!this.movable && !movable) return;
    
    if (movable) {
        addMouseListener(mouseListener);
        addMouseMotionListener((MouseMotionListener) mouseListener);
    }
    else {
        removeMouseListener(mouseListener);
        removeMouseMotionListener((MouseMotionListener) mouseListener);
    }
    
    movable = !movable;
}
 
开发者ID:ArrowLuo,项目名称:FCMFrame,代码行数:24,代码来源:CCSystem.java

示例12: addCurrentLineHighlightListeners

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Adds listeners that listen for changes to the current line, so we can
 * update our "current line highlight."  This is needed only because of an
 * apparent difference between the JRE 1.4.2 and 1.5.0 (needed on 1.4.2,
 * not needed on 1.5.0).
 */
private void addCurrentLineHighlightListeners() {
	boolean add = true;
	MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
	for (int i=0; i<mouseMotionListeners.length; i++) {
		if (mouseMotionListeners[i]==mouseListener) {
			add = false;
			break;
		}
	}
	if (add==true) {
		//System.err.println("Adding mouse motion listener!");
		addMouseMotionListener(mouseListener);
	}
	MouseListener[] mouseListeners = getMouseListeners();
	for (int i=0; i<mouseListeners.length; i++) {
		if (mouseListeners[i]==mouseListener) {
			add = false;
			break;
		}
	}
	if (add==true) {
		//System.err.println("Adding mouse listener!");
		addMouseListener(mouseListener);
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:32,代码来源:RTextAreaBase.java

示例13: addCurrentLineHighlightListeners

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
/**
 * Adds listeners that listen for changes to the current line, so we can update our "current line highlight." This
 * is needed only because of an apparent difference between the JRE 1.4.2 and 1.5.0 (needed on 1.4.2, not needed on
 * 1.5.0).
 */
protected void addCurrentLineHighlightListeners() {
    boolean add = true;
    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (int i = 0; i < mouseMotionListeners.length; i++) {
        if (mouseMotionListeners[i] == mouseListener) {
            add = false;
            break;
        }
    }
    if (add == true) {
        // System.err.println("Adding mouse motion listener!");
        addMouseMotionListener(mouseListener);
    }
    MouseListener[] mouseListeners = getMouseListeners();
    for (int i = 0; i < mouseListeners.length; i++) {
        if (mouseListeners[i] == mouseListener) {
            add = false;
            break;
        }
    }
    if (add == true) {
        // System.err.println("Adding mouse listener!");
        addMouseListener(mouseListener);
    }
}
 
开发者ID:intuit,项目名称:Tank,代码行数:31,代码来源:RTextAreaBase.java

示例14: notifyMouseMotionListeners

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
public void notifyMouseMotionListeners(final MouseEvent e) {
    SwingWorker worker = new SwingWorker<String, Object>() {

        @Override
        public String doInBackground() {
            if (mouseMotionListeners != null) {
                e.setSource(this);
                ListIterator<MouseMotionListener> iter = mouseMotionListeners.listIterator();
                while (iter.hasNext()) {
                    MouseMotionListener listener = iter.next();

                    switch (e.getID()) {
                        case MouseEvent.MOUSE_MOVED:
                            listener.mouseMoved(e);
                            break;
                        case MouseEvent.MOUSE_DRAGGED:
                            listener.mouseDragged(e);
                            break;
                        default:
                            break;
                    }
                }
                iter = null;
            }
            return null;
        }
    };
    worker.execute();
    try {
        worker.get();
    } catch (Exception ie) {
    }
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:34,代码来源:HUDFrameHeader2D.java

示例15: notifyMouseMotionListeners

import java.awt.event.MouseMotionListener; //导入依赖的package包/类
public void notifyMouseMotionListeners(MouseEvent e) {
    if (mouseMotionListeners != null) {
        e.setSource(this);
        ListIterator<MouseMotionListener> iter = mouseMotionListeners.listIterator();
        while (iter.hasNext()) {
            MouseMotionListener listener = iter.next();

            switch (e.getID()) {
                case MouseEvent.MOUSE_MOVED:
                    listener.mouseMoved(e);
                    break;
                case MouseEvent.MOUSE_DRAGGED:
                    listener.mouseDragged(e);
                    break;
                default:
                    break;
            }
        }
        iter = null;
    }
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:22,代码来源:HUDView2D.java


注:本文中的java.awt.event.MouseMotionListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。