Here you can find the source of resetPosition(Window window1, Window window2)
private static void resetPosition(Window window1, Window window2)
//package com.java2s; import java.awt.Rectangle; import java.awt.Window; public class Main { private static void resetPosition(Window window1, Window window2) { Rectangle r1 = window1.getBounds(); Rectangle r2 = window2.getBounds(); int lowerEdge = (int) r2.getY() + (int) r2.getHeight(); int rightEdge = (int) r2.getX() + (int) r2.getWidth(); if ((int) r1.getY() < lowerEdge && (int) r1.getX() < rightEdge) { r1.setLocation((int) r1.getX(), lowerEdge); window1.setBounds(r1);// w ww.j a v a 2 s. c o m } } }