Java tutorial
//package com.java2s; //License from project: Apache License import java.awt.Component; public class Main { static int getY(final Component component) { final int y = component.getY(); final Component parent = component.getParent(); if (parent == null) { return y; } else { return y + getY(parent); } } }