Java Code Examples for java.awt.Component#addMouseMotionListener()
The following examples show how to use
java.awt.Component#addMouseMotionListener() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: gcs File: MouseCapture.java License: Mozilla Public License 2.0 | 6 votes |
/** * Starts redirecting all mouse events to the specified component or one of its children. * * @param component The target. * @param cursor The cursor to use while the mouse is captured. */ public static void start(Component component, Cursor cursor) { JRootPane rootPane = SwingUtilities.getRootPane(component); if (rootPane != null) { Component glassPane = rootPane.getGlassPane(); MouseCapture capture = new MouseCapture(glassPane, component); glassPane.addMouseListener(capture); glassPane.addMouseMotionListener(capture); glassPane.addHierarchyListener(capture); if (cursor != null) { glassPane.setCursor(cursor); } MAP.put(component, capture); glassPane.setVisible(true); } }
Example 2
Source Project: pumpernickel File: MagnificationPanel.java License: MIT License | 5 votes |
/** * Add MouseListeners to a component and its children. If children have a * MouseListener for mouse-moved events, then this component won't otherwise * receive mouse-moved events (and therefore it won't repaint correctly). * <p> * A common instance of this problem is simply the presence of tooltips * (which require a MouseListener). */ private void addMouseListeners(Component c) { c.addMouseMotionListener(mouseListener); c.addMouseListener(mouseListener); if (c instanceof Container) { Container c2 = (Container) c; c2.addContainerListener(containerListener); for (Component child : c2.getComponents()) { addMouseListeners(child); } } }
Example 3
Source Project: pumpernickel File: DescendantMouseListener.java License: MIT License | 5 votes |
/** * Add all our internal listeners from a component and its descendants. */ private void addListeners(DefaultMutableTreeNode componentNode) { Component c = (Component) componentNode.getUserObject(); c.addHierarchyListener(hierarchyListener); c.addMouseListener(mouseListener); c.addMouseMotionListener(mouseListener); for (int a = 0; a < componentNode.getChildCount(); a++) { addListeners((DefaultMutableTreeNode) componentNode.getChildAt(a)); } if (c instanceof Container) ((Container) c).addContainerListener(containerListener); }
Example 4
Source Project: jmonkeyengine File: AWTMouseInput.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void bind(Component component) { super.bind(component); component.addMouseListener(this); component.addMouseMotionListener(this); component.addMouseWheelListener(this); }
Example 5
Source Project: settlers-remake File: GOSwingEventConverter.java License: MIT License | 5 votes |
/** * Creates a new event converter, that converts swing events to go events. * * @param component * The component. * @param provider * THe provider to which to send the events. */ public GOSwingEventConverter(Component component, GOEventHandlerProvider provider) { super(provider); component.setFocusTraversalKeysEnabled(false); component.addKeyListener(this); component.addMouseListener(this); component.addMouseMotionListener(this); component.addMouseWheelListener(this); component.addHierarchyListener(this); addReplaceRule(new EventReplacementRule(ReplacableEvent.DRAW, Replacement.COMMAND_SELECT, MOUSE_TIME_TRSHOLD, MOUSE_MOVE_TRESHOLD)); addReplaceRule(new EventReplacementRule(ReplacableEvent.PAN, Replacement.COMMAND_ACTION, MOUSE_TIME_TRSHOLD, MOUSE_MOVE_TRESHOLD)); }
Example 6
Source Project: amodeus File: LazyMouse.java License: GNU General Public License v2.0 | 4 votes |
public void addListenersTo(Component myComponent) { myComponent.addMouseListener(this); myComponent.addMouseMotionListener(this); }
Example 7
Source Project: Pixelitor File: DragReorderHandler.java License: GNU General Public License v3.0 | 4 votes |
public void attachToComponent(Component c) { c.addMouseListener(this); c.addMouseMotionListener(this); }
Example 8
Source Project: jclic File: GlobalMouseAdapter.java License: GNU General Public License v2.0 | 4 votes |
public void attachTo(Component cmp, boolean catchMotion) { cmp.addMouseListener(this); if (catchMotion) cmp.addMouseMotionListener(this); }
Example 9
Source Project: Cognizant-Intelligent-Test-Scripter File: WindowMover.java License: Apache License 2.0 | 2 votes |
private void addListeners(Component com) { com.addMouseListener(ma); com.addMouseMotionListener(mma); }