get Location In Window - Java Swing

Java examples for Swing:Screen

Description

get Location In Window

Demo Code


//package com.java2s;
import java.awt.Component;
import java.awt.Point;
import java.awt.Window;

public class Main {
    public static Point getLocationInWindow(Component c, Window w) {
        Point cPoint = c.getLocationOnScreen();
        Point wPoint = w.getLocationOnScreen();
        return new Point(cPoint.x - wPoint.x, cPoint.y - wPoint.y);
    }/*w w  w .ja  va 2s  .  c  o m*/
}

Related Tutorials