本文整理了Java中java.awt.event.MouseMotionListener
类的一些代码示例,展示了MouseMotionListener
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MouseMotionListener
类的具体详情如下:
包路径:java.awt.event.MouseMotionListener
类名称:MouseMotionListener
[英]The listener interface for receiving mouse motion events on a component. (For clicks and other mouse events, use the MouseListener
.)
The class that is interested in processing a mouse motion event either implements this interface (and all the methods it contains) or extends the abstract MouseMotionAdapter
class (overriding only the methods of interest).
The listener object created from that class is then registered with a component using the component's addMouseMotionListener
method. A mouse motion event is generated when the mouse is moved or dragged. (Many such events will be generated). When a mouse motion event occurs, the relevant method in the listener object is invoked, and the MouseEvent
is passed to it.
[中]用于接收组件上鼠标运动事件的侦听器接口。(对于点击和其他鼠标事件,请使用MouseListener
。)
对处理鼠标运动事件感兴趣的类要么实现此接口(及其包含的所有方法),要么扩展抽象MouseMotionAdapter
类(仅覆盖感兴趣的方法)。
然后使用组件的addMouseMotionListener
方法向组件注册从该类创建的侦听器对象。移动或拖动鼠标时会生成鼠标运动事件。(将产生许多这样的事件)。当鼠标移动事件发生时,将调用侦听器对象中的相关方法,并将MouseEvent
传递给它。
代码示例来源:origin: stackoverflow.com
protected void processMouseMotionEvent(MouseEvent e) {
MouseMotionListener listener = mouseMotionListener;
if (listener != null) {
int id = e.getID();
switch(id) {
case MouseEvent.MOUSE_MOVED:
listener.mouseMoved(e);
break;
case MouseEvent.MOUSE_DRAGGED:
listener.mouseDragged(e);
break;
}
}
}
代码示例来源:origin: com.jidesoft/jide-oss
public void mouseMoved(MouseEvent e) {
if (_listener != null) {
_listener.mouseMoved(e);
}
}
}
代码示例来源:origin: com.jidesoft/jide-oss
public void mouseDragged(MouseEvent e) {
if (_listener != null) {
_listener.mouseDragged(e);
}
}
代码示例来源:origin: eu.mihosoft.vrl/vrl
@Override
public void mouseMoved(MouseEvent e) {
for (MouseMotionListener eL : externalListeners) {
eL.mouseMoved(e);
}
}
});
代码示例来源:origin: girtel/Net2Plan
@Override
public void mouseDragged(MouseEvent e) {
if (plugin instanceof MouseMotionListener)
((MouseMotionListener) plugin).mouseDragged(e);
}
代码示例来源:origin: edu.stanford.protege/org.coode.owlviz
mouseMotionListeners[i].mouseMoved(e);
mouseMotionListeners[i].mouseDragged(e);
代码示例来源:origin: girtel/Net2Plan
@Override
public void mouseMoved(MouseEvent e) {
if (plugin instanceof MouseMotionListener)
((MouseMotionListener) plugin).mouseMoved(e);
}
代码示例来源:origin: xyz.cofe/docking-frames-core
public void mouseDragged( MouseEvent e ) {
for( MouseMotionListener m : mouseMotionListeners.toArray( new MouseMotionListener[ mouseMotionListeners.size() ] ))
m.mouseDragged( e );
}
代码示例来源:origin: sarahtattersall/PIPE
/**
* Translates the event to a zoomed event point
* @param e mouse event
* @param l component
*/
@Override
protected void processMouseMotionEvent(MouseEvent e, JLayer<? extends JComponent> l) {
MouseEvent localEvent = translateToLayerCoordinates(e, l);
if (clickNotOutOfBounds(localEvent, l)) {
Component component = getComponentClickedOn(l, localEvent);
if (localEvent.getID() == MouseEvent.MOUSE_MOVED) {
for (MouseMotionListener listener : component.getListeners(MouseMotionListener.class)) {
listener.mouseMoved(getNewMouseClickEvent(component, localEvent));
}
} else if (localEvent.getID() == MouseEvent.MOUSE_DRAGGED) {
for (MouseMotionListener listener : component.getListeners(MouseMotionListener.class)) {
listener.mouseDragged(getNewMouseClickEvent(component, localEvent));
}
}
}
e.consume();
}
代码示例来源:origin: xyz.cofe/docking-frames-core
public void mouseMoved( MouseEvent e ) {
for( MouseMotionListener m : mouseMotionListeners.toArray( new MouseMotionListener[ mouseMotionListeners.size() ] ))
m.mouseMoved( e );
}
};
代码示例来源:origin: sc.fiji/fiji-lib
@Override
public final void mouseDragged(MouseEvent e) {
if (isThisTool())
listener.mouseDragged(e);
}
代码示例来源:origin: stackoverflow.com
public void mouseDragged(MouseEvent e) {
if (!SwingUtilities.isLeftMouseButton(e)) return;
motionDelegate.mouseDragged(e);
motionDelegate.mouseMoved(e);
代码示例来源:origin: sc.fiji/fiji-lib
@Override
public final void mouseMoved(MouseEvent e) {
if (isThisTool())
listener.mouseMoved(e);
}
}
代码示例来源:origin: eu.mihosoft.vrl/vrl
@Override
public void mouseDragged(MouseEvent e) {
location = e.getLocationOnScreen();
resizeTarget();
for (MouseMotionListener eL : externalListeners) {
eL.mouseDragged(e);
}
}
代码示例来源:origin: google/sagetv
((java.awt.event.MouseMotionListener) mouseMotionListeners.elementAt(i)).mouseMoved(evt);
break;
case java.awt.event.MouseEvent.MOUSE_DRAGGED:
((java.awt.event.MouseMotionListener) mouseMotionListeners.elementAt(i)).mouseDragged(evt);
break;
代码示例来源:origin: com.github.tornaia/aott-desktop-client-core
@Override
public void mouseExited(MouseEvent e) {
toolTips.getMouseMotionListener().mouseMoved(e);
}
});
代码示例来源:origin: sc.fiji/fiji-lib
@Override
public final void mouseDragged(MouseEvent e) {
if (!e.isConsumed())
listener.mouseDragged(e);
}
代码示例来源:origin: org.opentcs.thirdparty.dockingframes/docking-frames-core
case MouseEvent.MOUSE_DRAGGED:
for( MouseMotionListener listener : getMouseMotionListeners() ){
listener.mouseDragged( event );
case MouseEvent.MOUSE_MOVED:
for( MouseMotionListener listener : getMouseMotionListeners() ){
listener.mouseMoved( event );
代码示例来源:origin: sc.fiji/fiji-lib
@Override
public final void mouseMoved(MouseEvent e) {
if (!e.isConsumed())
listener.mouseMoved(e);
}
}
代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf
public void mouseDragged(MouseEvent e) {
for (MouseMotionListener listener : eventListenerList.getListeners(MouseMotionListener.class))
listener.mouseDragged(e);
}
内容来源于网络,如有侵权,请联系作者删除!