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

The following examples show how to use javax.swing.SwingUtilities#convertMouseEvent() . 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: marathonv5   File: ContextMenuWindow.java    License: 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 Project: stendhal   File: DragLayer.java    License: 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
/**
 * 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 4
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
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 6
Source Project: jdk8u60   File: bug7170657.java    License: 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 7
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 Project: chipster   File: EditableHeaderUI.java    License: 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 9
Source Project: netbeans   File: JCheckTree.java    License: 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 10
Source Project: netbeans   File: JExtendedTree.java    License: 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 11
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
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 13
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 Project: hottub   File: bug7170657.java    License: 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 15
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 16
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 17
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
private boolean repostEvent(MouseEvent e) {
	if (dispatchComponent == null) {
		return false;
	}
	MouseEvent e2 = SwingUtilities.convertMouseEvent(header, e, dispatchComponent);
	dispatchComponent.dispatchEvent(e2);
	return true;
}
 
Example 19
private void processEvent(MouseEvent e)
{
	if (SwingUtilities.isLeftMouseButton(e))
	{
		MouseEvent eventForTarget = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, target);
		target.dispatchEvent(eventForTarget);
	}
}
 
Example 20
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);
    }
}