Java Swing Mouse parentMouseEvent(JComponent c, MouseEvent m)

Here you can find the source of parentMouseEvent(JComponent c, MouseEvent m)

Description

build a moue event on the parent coordinates

License

Apache License

Parameter

Parameter Description
c relative component
m mopuse event

Return

non-null new mouse event

Declaration

public static MouseEvent parentMouseEvent(JComponent c, MouseEvent m) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.swing.*;

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

public class Main {
    /**//from   www  .  j a  v a2s.c  om
     * build a moue event on the parent coordinates
     *
     * @param c relative component
     * @param m mopuse event
     * @return non-null new mouse event
     */
    public static MouseEvent parentMouseEvent(JComponent c, MouseEvent m) {
        Point loc = c.getLocation();
        int x = m.getX() + loc.x;
        int y = m.getY() + loc.y;
        MouseEvent ret = new MouseEvent(c.getParent(), m.getID(), m.getWhen(), m.getModifiers(), x, y,
                m.getClickCount(), m.isPopupTrigger(), m.getButton());
        return ret;
    }
}

Related

  1. isPopupTrigger(final MouseEvent e)
  2. isPrimaryMouseButton(MouseEvent e)
  3. makeMouseOverBorder(final JComponent b)
  4. mapDragOperationFromModifiers(MouseEvent me, TransferHandler th)
  5. paintBandTitle(Graphics g, Rectangle titleRectangle, String title, boolean isUnderMouse, boolean hasExpandIcon)
  6. passBehind(MouseEvent e)
  7. propagate(MouseEvent e, Component c)
  8. removeMouseListenerToHierarchy(JComponent c, MouseListener listener)
  9. removePopup(JComponent mouseEvtComp)