*/
public static void positionDialogRelativeToParent(final Dialog dialog,
final double horizontalPercent,
final double verticalPercent)
{
final Container parent = dialog.getParent();
if (parent == null || (parent.isVisible() == false))
{
positionFrameOnScreen(dialog, horizontalPercent, verticalPercent);
return;
}
final Dimension d = dialog.getSize();
final Dimension p = parent.getSize();
final int baseX = parent.getX();
final int baseY = parent.getY();
final int parentPointX = baseX + (int) (horizontalPercent * p.width);
final int parentPointY = baseY + (int) (verticalPercent * p.height);
final int dialogPointX = Math.max (0, parentPointX - (int) (horizontalPercent * d.width));
final int dialogPointY = Math.max (0, parentPointY - (int) (verticalPercent * d.height));
// make sure the dialog fits completely on the screen...
final Rectangle s = parent.getGraphicsConfiguration().getBounds();
final Rectangle r = new Rectangle(dialogPointX, dialogPointY, d.width, d.height);
final Rectangle intersectedDialogBounds = r.intersection(s);
if (intersectedDialogBounds.width < d.width)
{
r.x = s.width - d.width;