Here you can find the source of getWindowLocation(JComponent start)
Parameter | Description |
---|---|
start | - starting component |
theClass | - required class |
public static Point getWindowLocation(JComponent start)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.*; public class Main { /**/*from ww w. j a va2s. c o m*/ * search of the hierarcy of components for an instance of a given class * * @param start - starting component * @param theClass - required class * @return possibly null component - null says no ancestor found */ public static Point getWindowLocation(JComponent start) { Point loc = start.getLocation(); Container parent = start.getParent(); if (parent == null) return loc; if (parent instanceof JComponent) { Point ancestorLoc = getWindowLocation((JComponent) parent); return new Point(loc.x + ancestorLoc.x, loc.y + ancestorLoc.y); } else { return loc; } } }