Here you can find the source of delegateEventToParent(Component component, MouseEvent e)
Parameter | Description |
---|---|
component | component to get parent from. |
e | event to send. |
public static void delegateEventToParent(Component component, MouseEvent e)
//package com.java2s; // the terms of the GNU General Public License as published by the Free Software Foundation; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; public class Main { /**/*from w w w. j a v a2 s . c o m*/ * Sends event to parent in it's coordinate space. * * @param component component to get parent from. * @param e event to send. */ public static void delegateEventToParent(Component component, MouseEvent e) { delegateEventToParent(component, e, false); } /** * Sends event to parent in it's coordinate space (if <code>direct</code> isn't set). * * @param component component to get parent from. * @param e event to send. * @param direct <code>TRUE</code> for direct delegation (no conversion to parent coord. space). */ public static void delegateEventToParent(Component component, MouseEvent e, boolean direct) { Component parent = component.getParent(); delegateEventToParent(component, parent, e, direct); } /** * Sends event to parent in it's coordinate space (if <code>direct</code> isn't set). * * @param component component to get parent from. * @param parent parent component. * @param e event to send. * @param direct <code>TRUE</code> for direct delegation (no conversion to parent coord. space). */ public static void delegateEventToParent(Component component, Component parent, MouseEvent e, boolean direct) { if (parent != null) { if (direct) { e = new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); } else { Point point = e.getPoint(); SwingUtilities.convertPointToScreen(point, component); SwingUtilities.convertPointFromScreen(point, parent); e = new MouseEvent(parent, e.getID(), e.getWhen(), e.getModifiers(), (int) point.getX(), (int) point.getY(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); } parent.dispatchEvent(e); } } /** * Sends event to parent. * * @param component component to get parent from. * @param e event to send. */ public static void delegateEventToParent(Component component, AWTEvent e) { Component parent = component.getParent(); if (parent != null) parent.dispatchEvent(e); } }