Java tutorial
//package com.java2s; import java.awt.Component; import javax.swing.SwingUtilities; public class Main { /** * Tests if 2 components - a and b, desecents from the same root * * @param a * @param b * @return */ public static boolean DesecendsFromSameFrame(Component a, Component b) { return SwingUtilities.getRoot(a) == SwingUtilities.getRoot(b); } }