Java Swing Mouse retargetMouseEvent(int id, MouseEvent e, Component target)

Here you can find the source of retargetMouseEvent(int id, MouseEvent e, Component target)

Description

retarget Mouse Event

License

Open Source License

Declaration

public static void retargetMouseEvent(int id, MouseEvent e,
            Component target) 

Method Source Code

//package com.java2s;
import javax.swing.*;

import java.awt.*;
import java.awt.event.*;

public class Main {
    public static void retargetMouseEvent(int id, MouseEvent e,
            Component target) {/*from  w w  w.  j  av  a 2s .  c  o  m*/
        if (target == null || (target == e.getSource() && id == e.getID())) {
            return;
        }
        if (e.isConsumed()) {
            return;
        }

        // fix for bug #4202966 -- hania
        // When re-targeting a mouse event, we need to translate
        // the event's coordinates relative to the target.

        Point p = SwingUtilities.convertPoint((Component) e.getSource(),
                e.getX(), e.getY(), target);
        MouseEvent retargeted = new MouseEvent(target, id, e.getWhen(),
                e.getModifiersEx() | e.getModifiers(), p.x, p.y,
                e.getClickCount(), e.isPopupTrigger(), e.getButton());
        target.dispatchEvent(retargeted);
    }
}

Related

  1. parentMouseEvent(JComponent c, MouseEvent m)
  2. passBehind(MouseEvent e)
  3. propagate(MouseEvent e, Component c)
  4. removeMouseListenerToHierarchy(JComponent c, MouseListener listener)
  5. removePopup(JComponent mouseEvtComp)
  6. retargetMouseEvent(int id, MouseEvent e, Component target)
  7. retargetMouseEvent(MouseEvent e, Component target)
  8. rowAtPoint(MouseEvent mouseEvent)
  9. setHintOnMouseHover(JComponent view, String tooltip, JLabel onView)