public void positionDialogRelativeToParent(final JDialog dialog,final double horizontalPercent,final double verticalPercent){
  final Dimension d=dialog.getSize();
  final Dimension p=mainFrame.getSize();
  final int baseX=mainFrame.getX() - d.width;
  final int baseY=mainFrame.getY() - d.height;
  final int w=d.width + p.width;
  final int h=d.height + p.height;
  int x=baseX + (int)(horizontalPercent * w);
  int y=baseY + (int)(verticalPercent * h);
  final Rectangle s=getMaximumWindowBounds();
  x=Math.min(x,(s.width - d.width));
  x=Math.max(x,0);
  y=Math.min(y,(s.height - d.height));
  y=Math.max(y,0);
  dialog.setBounds(x + s.x,y + s.y,d.width,d.height);
}

public void positionDialogRelativeToParent ( final JDialog dialog , final double horizontalPercent , final double verticalPercent ) { final Dimension d = dialog . getSize ( ) ; final Dimension p = mainFrame . getSize ( ) ; final int baseX = mainFrame . getX ( ) - d . width ; final int baseY = mainFrame . getY ( ) - d . height ; final int w = d . width + p . width ; final int h = d . height + p . height ; int x = baseX + ( int ) ( horizontalPercent * w ) ; int y = baseY + ( int ) ( verticalPercent * h ) ; final Rectangle s = getMaximumWindowBounds ( ) ; x = Math . min ( x , ( s . width - d . width ) ) ; x = Math . max ( x , 0 ) ; y = Math . min ( y , ( s . height - d . height ) ) ; y = Math . max ( y , 0 ) ; dialog . setBounds ( x + s . x , y + s . y , d . width , d . height ) ; }
positions the specified dialog at a position relative to its parent .
