Java Code Examples for javax.swing.SwingUtilities#convertMouseEvent()

The following examples show how to use javax.swing.SwingUtilities#convertMouseEvent() . 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 File: ContextMenuWindow.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override
public void eventDispatched(AWTEvent event) {
    if (ignoreMouseEvents) {
        return;
    }
    Component root = SwingUtilities.getRoot((Component) event.getSource());
    if (root instanceof IRecordingArtifact || root.getName().startsWith("###")) {
        return;
    }
    if (!(event instanceof MouseEvent)) {
        return;
    }
    MouseEvent mouseEvent = (MouseEvent) event;
    mouseEvent.consume();
    if (event.getID() == MouseEvent.MOUSE_PRESSED) {
        disposeOverlay();
        Component mouseComponent = SwingUtilities.getDeepestComponentAt(mouseEvent.getComponent(), mouseEvent.getX(),
                mouseEvent.getY());
        if (mouseComponent == null) {
            return;
        }
        mouseEvent = SwingUtilities.convertMouseEvent(mouseEvent.getComponent(), mouseEvent, mouseComponent);
        setComponent(mouseComponent, mouseEvent.getPoint(), true);
        return;
    }
}
 
Example 2
Source File: DragLayer.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void eventDispatched(AWTEvent e) {
	if (e instanceof MouseEvent) {
		MouseEvent event = (MouseEvent) e;

		MouseEvent converted = SwingUtilities.convertMouseEvent(event.getComponent(), event, this);
		point = converted.getPoint();

		if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
			underlyingComponent = null;
			requestDraw();
		} else if ((event.getID() == MouseEvent.MOUSE_RELEASED) && (dragged != null)) {
			underlyingComponent = null;
			stopDrag(event);
			requestDraw();
			point = null;
		}
		// We are interested only in DnD, so we can ignore any other events
	}
}
 
Example 3
Source File: bug7170657.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 4
Source File: bug7170657.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 5
Source File: MouseDragEventForwarder.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void processEvent(MouseEvent e)
{
	if (SwingUtilities.isLeftMouseButton(e))
	{
		MouseEvent eventForTarget = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, target);
		target.dispatchEvent(eventForTarget);
	}
}
 
Example 6
Source File: EditableTableHeaderUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private boolean repostEvent(MouseEvent e) {
	if (dispatchComponent == null) {
		return false;
	}
	MouseEvent e2 = SwingUtilities.convertMouseEvent(header, e, dispatchComponent);
	dispatchComponent.dispatchEvent(e2);
	return true;
}
 
Example 7
Source File: bug7170657.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 8
Source File: JCheckTree.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void processMouseEvent(MouseEvent e) {
    if (e instanceof MouseWheelEvent) {
        Component target = JCheckTree.this.getParent();
        if (target == null || !(target instanceof JViewport))
            target = JCheckTree.this;
        MouseEvent mwe = SwingUtilities.convertMouseEvent(
                JCheckTree.this, (MouseWheelEvent)e, target);
        target.dispatchEvent((MouseWheelEvent)mwe);
    } else {
        super.processMouseEvent((MouseEvent)e);
    }
}
 
Example 9
Source File: bug7170657.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 10
Source File: bug7170657.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 11
Source File: bug7170657.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 12
Source File: mxSelectionCellsHandler.java    From blog-codes with Apache License 2.0 5 votes vote down vote up
/**
 * Redirects the tooltip handling of the JComponent to the graph
 * component, which in turn may use getHandleToolTipText in this class to
 * find a tooltip associated with a handle.
 */
public String getToolTipText(MouseEvent e)
{
	MouseEvent tmp = SwingUtilities.convertMouseEvent(e.getComponent(), e,
			graphComponent.getGraphControl());
	Iterator<mxCellHandler> it = handlers.values().iterator();
	String tip = null;

	while (it.hasNext() && tip == null)
	{
		tip = it.next().getToolTipText(tmp);
	}

	return tip;
}
 
Example 13
Source File: bug7170657.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 14
Source File: JExtendedTree.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void processMouseEvent(MouseEvent e) {
    if (e instanceof MouseWheelEvent) {
        Component target = JExtendedTree.this.getParent();
        if (target == null || !(target instanceof JViewport))
            target = JExtendedTree.this;
        MouseEvent mwe = SwingUtilities.convertMouseEvent(
                JExtendedTree.this, (MouseWheelEvent)e, target);
        target.dispatchEvent((MouseWheelEvent)mwe);
    } else {
        super.processMouseEvent((MouseEvent)e);
    }
}
 
Example 15
Source File: JCheckTree.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void processMouseEvent(MouseEvent e) {
    if (e instanceof MouseWheelEvent) {
        Component target = JCheckTree.this.getParent();
        if (target == null || !(target instanceof JViewport))
            target = JCheckTree.this;
        MouseEvent mwe = SwingUtilities.convertMouseEvent(
                JCheckTree.this, (MouseWheelEvent)e, target);
        target.dispatchEvent((MouseWheelEvent)mwe);
    } else {
        super.processMouseEvent((MouseEvent)e);
    }
}
 
Example 16
Source File: EditableHeaderUI.java    From chipster with MIT License 5 votes vote down vote up
private boolean repostEvent(MouseEvent e) { 
	if (dispatchComponent == null) {
		return false; 
	}
	MouseEvent e2 = SwingUtilities.convertMouseEvent(header, e, dispatchComponent);
	dispatchComponent.dispatchEvent(e2); 
	return true; 
}
 
Example 17
Source File: bug7170657.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 18
Source File: bug7170657.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 19
Source File: bug7170657.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 20
Source File: bug7170657.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}