Java 类java.awt.event.MouseMotionListener 实例源码
项目:Parabot-317-API-Minified-PkHonor
文件:ScriptEngine.java
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);
}
}
项目:Parabot-317-API-Minified-Dreamscape
文件:ScriptEngine.java
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);
}
}
项目:powertext
文件:RTextAreaBase.java
/**
* 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);
}
}
项目:freecol
文件:Canvas.java
/**
* 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;
}
项目:freecol
文件:Canvas.java
/**
* 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);
}
}
项目:freecol
文件:InGameMenuBar.java
/**
* 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();
}
项目:VTerminal
文件:Panel.java
/**
* 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.");
}
项目:VTerminal
文件:Panel.java
/**
* 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.");
}
项目:Parabot-317-API-Minified-OS-Scape
文件:ScriptEngine.java
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);
// }
}
项目:Cognizant-Intelligent-Test-Scripter
文件:SelectionManager.java
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();
}
项目:FreeCol
文件:Canvas.java
/**
* 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;
}
项目:FreeCol
文件:Canvas.java
/**
* 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);
}
}
项目:FreeCol
文件:InGameMenuBar.java
/**
* 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();
}
项目:PhET
文件:ApparatusPanel.java
/**
* 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 );
}
项目:FCMFrame
文件:CCSystem.java
/**
* 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;
}
项目:ftc
文件:RTextAreaBase.java
/**
* 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);
}
}
项目:Tank
文件:RTextAreaBase.java
/**
* 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);
}
}
项目:Tank
文件:RTextAreaBase.java
/**
* 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);
}
}
项目:ESPlorer
文件:RTextAreaBase.java
/**
* 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);
}
}
项目:openwonderland
文件:HUDFrameHeader2D.java
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) {
}
}
项目:openwonderland
文件:HUDView2D.java
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;
}
}
项目:openwonderland
文件:Window2D.java
/**
* Deliver the given mouse motion event to the window.
*
* @param event The mouse motion event to deliver.
*/
private void deliverMouseMotionEvent(MouseEvent event) {
if (mouseMotionListeners == null) {
return;
}
for (MouseMotionListener listener : mouseMotionListeners) {
switch (event.getID()) {
case MouseEvent.MOUSE_MOVED:
listener.mouseMoved(event);
break;
case MouseEvent.MOUSE_DRAGGED:
listener.mouseDragged(event);
break;
}
}
}
项目:openwonderland
文件:Window2D.java
/**
* Remove a listener for mouse motion events.
*
* @param listener The mouse motion listener to remove.
*/
public void removeMouseMotionListener(MouseMotionListener listener) {
if (app == null) {
return;
}
synchronized (app.getAppCleanupLock()) {
synchronized (this) {
if (mouseMotionListeners == null) {
return;
}
mouseMotionListeners.remove(listener);
if (mouseMotionListeners.size() == 0) {
mouseMotionListeners = null;
}
}
}
}
项目:openwonderland
文件:HeaderPanel.java
@Override
public void addMouseMotionListener(final MouseMotionListener listener) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
HeaderPanel.super.addMouseMotionListener(listener);
if (appLabel != null) {
appLabel.addMouseMotionListener(listener);
}
if (controllerLabel != null) {
controllerLabel.addMouseMotionListener(listener);
}
if (closeButton != null) {
closeButton.addMouseMotionListener(listener);
}
if (hudButton != null) {
hudButton.addMouseMotionListener(listener);
}
}
});
}
项目:openwonderland
文件:HeaderPanel.java
@Override
public void removeMouseMotionListener(final MouseMotionListener listener) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
HeaderPanel.super.removeMouseMotionListener(listener);
if (appLabel != null) {
appLabel.removeMouseMotionListener(listener);
}
if (controllerLabel != null) {
controllerLabel.removeMouseMotionListener(listener);
}
if (closeButton != null) {
closeButton.removeMouseMotionListener(listener);
}
if (hudButton != null) {
hudButton.removeMouseMotionListener(listener);
}
}
});
}
项目:power-matchmaker
文件:MungePen.java
/**
* Removes all listeners associated with the given Component. This is useful when removing to to make sure
* it does not stick around.
*/
public static void removeAllListeners(Component com) {
for (FocusListener fl : com.getFocusListeners()) {
com.removeFocusListener(fl);
}
for (MouseListener ml : com.getMouseListeners()) {
com.removeMouseListener(ml);
}
for (MouseMotionListener mml : com.getMouseMotionListeners()) {
com.removeMouseMotionListener(mml);
}
for (KeyListener kl : com.getKeyListeners()) {
com.removeKeyListener(kl);
}
for (ComponentListener cl : com.getComponentListeners()) {
com.removeComponentListener(cl);
}
}
项目:kkMulticopterFlashTool
文件:SelectionManager.java
public void mouseClicked(MouseEvent event)
{
if ((activeObject != null) && activeObject.contains(event.getX(), event.getY()))
{
eventRelay.relay("mouseClicked", event);
}
else
{
if (event.getClickCount() == 2)
{
if (selectedObject != null)
{
activeObject = selectedObject;
Component component = activeObject.getComponent();
if (component != null)
{
eventRelay.reset();
eventRelay.addTarget(component, MouseListener.class, MouseEvent.class, mouseNames);
eventRelay.addTarget(component, MouseMotionListener.class, MouseEvent.class, mouseMotionNames);
selectableContainer.select(selectedObject, false);
}
}
}
}
}
项目:kkMulticopterFlashTool
文件:MouseInterceptPanel.java
public void setMouseMotionIntercept(MouseMotionListener listener)
{
if (mouseMotionIntercept instanceof MouseMotionListener)
removeMouseMotionListener(mouseMotionIntercept);
mouseMotionIntercept = listener;
if (mouseMotionIntercept instanceof MouseMotionListener)
{
removeMouseMotionListener(this);
addMouseMotionListener(mouseMotionIntercept);
mouseMotionPassThrough = false;
}
else
{
addMouseMotionListener(this);
mouseMotionPassThrough = true;
}
}
项目:cn1
文件:MouseDispatcher.java
private void dispatchMotionEvent(PointerInfo info, NativeEvent event) {
propagateEvent(info, AWTEvent.MOUSE_MOTION_EVENT_MASK,
MouseMotionListener.class, false);
final Point pos = info.position;
if ((lastUnderMotion != info.src) ||
!lastLocalPos.equals(pos)) {
lastUnderMotion = info.src;
lastLocalPos = pos;
if (info.src.isIndirectlyEnabled()) {
toolkit.getSystemEventQueueImpl().postEvent(
new MouseEvent(info.src, event.getEventId(),
event.getTime(),
event.getInputModifiers(),
pos.x, pos.y, 0, false));
}
}
}
项目:cn1
文件:Component.java
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
if (ComponentListener.class.isAssignableFrom(listenerType)) {
return (T[]) getComponentListeners();
} else if (FocusListener.class.isAssignableFrom(listenerType)) {
return (T[]) getFocusListeners();
} else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
return (T[]) getHierarchyBoundsListeners();
} else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
return (T[]) getHierarchyListeners();
} else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
return (T[]) getInputMethodListeners();
} else if (KeyListener.class.isAssignableFrom(listenerType)) {
return (T[]) getKeyListeners();
} else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
return (T[]) getMouseWheelListeners();
} else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
return (T[]) getMouseMotionListeners();
} else if (MouseListener.class.isAssignableFrom(listenerType)) {
return (T[]) getMouseListeners();
} else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
return (T[]) getPropertyChangeListeners();
}
return (T[]) Array.newInstance(listenerType, 0);
}
项目:ESPlorer
文件:RTextAreaBase.java
/**
* 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);
}
}
项目:Muloks
文件:Updater.java
/**
* Creates all listeners requested from the current state and adds them to
* the Listenerlist
*/
private void createListeners() {
eventListeners.addAll(StateManager.getInstance().getState().getListeners());
for (EventListener e : eventListeners) {
if (e instanceof KeyListener) {
canvas.addKeyListener((KeyListener) e);
} else if (e instanceof MouseMotionListener) {
canvas.addMouseMotionListener((MouseMotionListener) e);
} else if (e instanceof MouseListener) {
canvas.addMouseListener((MouseListener) e);
} else if (e instanceof CommandListener) {
CommandListener cl = (CommandListener) e;
cl.setUpdater(this);
StateManager.getInstance().getState().setCommandListener(cl);
} else {
System.err.println("Warning: Unimplemented listener listed in Updater");
}
}
}
项目:Muloks
文件:Updater.java
/**
* Destroys all listeners of the current state (use before creating a new state)
*/
private void destroyListeners() {
for (EventListener e : eventListeners) {
if (e instanceof KeyListener) {
canvas.removeKeyListener((KeyListener) e);
} else if (e instanceof MouseMotionListener) {
canvas.removeMouseMotionListener((MouseMotionListener) e);
} else if (e instanceof MouseListener) {
canvas.removeMouseListener((MouseListener) e);
} else if (e instanceof CommandListener); //No need to do anything here yet
else {
System.err.println("Warning: Unimplemented listener removed from Updater");
}
}
eventListeners.clear();
}
项目:Parabot-317-API-Minified
文件:ScriptEngine.java
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);
}
}
项目:BfROpenLab
文件:VisualizationViewer.java
/**
* a setter for the GraphMouse. This will remove any
* previous GraphMouse (including the one that
* is added in the initMouseClicker method.
* @param graphMouse new value
*/
public void setGraphMouse(GraphMouse graphMouse) {
this.graphMouse = graphMouse;
MouseListener[] ml = getMouseListeners();
for(int i=0; i<ml.length; i++) {
if(ml[i] instanceof GraphMouse) {
removeMouseListener(ml[i]);
}
}
MouseMotionListener[] mml = getMouseMotionListeners();
for(int i=0; i<mml.length; i++) {
if(mml[i] instanceof GraphMouse) {
removeMouseMotionListener(mml[i]);
}
}
MouseWheelListener[] mwl = getMouseWheelListeners();
for(int i=0; i<mwl.length; i++) {
if(mwl[i] instanceof GraphMouse) {
removeMouseWheelListener(mwl[i]);
}
}
addMouseListener(graphMouse);
addMouseMotionListener(graphMouse);
addMouseWheelListener(graphMouse);
}
项目:litiengine
文件:Mouse.java
@Override
public void registerMouseMotionListener(final MouseMotionListener listener) {
if (this.mouseMotionListeners.contains(listener)) {
return;
}
this.mouseMotionListeners.add(listener);
}
项目:litiengine
文件:Mouse.java
@Override
public void unregisterMouseMotionListener(final MouseMotionListener listener) {
if (!this.mouseMotionListeners.contains(listener)) {
return;
}
this.mouseMotionListeners.remove(listener);
}
项目:VASSAL-src
文件:PrivateMap.java
public synchronized void addMouseMotionListener(MouseMotionListener l) {
if (listenersActive) {
super.addMouseMotionListener(l);
}
else {
mouseMotionListeners.add(l);
}
}
项目:MapAnalyst
文件:JMapController.java
public JMapController(JMapViewer map) {
this.map = map;
if (this instanceof MouseListener)
map.addMouseListener((MouseListener) this);
if (this instanceof MouseWheelListener)
map.addMouseWheelListener((MouseWheelListener) this);
if (this instanceof MouseMotionListener)
map.addMouseMotionListener((MouseMotionListener) this);
}
项目:ramus
文件:Handler.java
/**
* Strips off the UI's mouse listeners attached to the associated toolbar
* and replaces them with this handler's listeners.
*/
private void installListeners() {
if (!ourVersionIsCompatible)
return;
ourToolBar.removePropertyChangeListener("UI", ourUIListener);
// Uninstall the current ui, collect the remaining listeners
// on the toolbar, and reinstall the ui...
final ComponentUI ui = ourToolBar.getUI();
ui.uninstallUI(ourToolBar);
final java.util.List mList = Arrays.asList(ourToolBar
.getListeners(MouseListener.class));
final java.util.List mmList = Arrays.asList(ourToolBar
.getListeners(MouseMotionListener.class));
ui.installUI(ourToolBar);
// ...then remove the listeners that were added by the ui...
final MouseListener[] ml = ourToolBar
.getListeners(MouseListener.class);
final MouseMotionListener[] mml = ourToolBar
.getListeners(MouseMotionListener.class);
for (int i = 0; i < ml.length; i++) {
if (!mList.contains(ml[i]))
ourToolBar.removeMouseListener(ml[i]);
}
for (int i = 0; i < mml.length; i++) {
if (!mmList.contains(mml[i]))
ourToolBar.removeMouseMotionListener(mml[i]);
}
// ...and add our listeners to the toolbar.
ourToolBar.addMouseListener(ourDragListener);
ourToolBar.addMouseMotionListener(ourDragListener);
ourToolBar.addPropertyChangeListener("UI", ourUIListener);
}