private class RepositionCallback implements Runnable {
private static final float GOLDEN_SECTION = 0.382f;
@Override
public void run() {
Dialog dialog = (Dialog)getComponent();
Container ancestor = dialog.getOwner();
if (ancestor == null) {
ancestor = dialog.getDisplay();
}
int deltaWidth = ancestor.getWidth() - getWidth();
int deltaHeight = ancestor.getHeight() - getHeight();
int x = Math.max(0, Math.round(ancestor.getX() + 0.5f * deltaWidth));
int y = Math.max(0, Math.round(ancestor.getY() + GOLDEN_SECTION * deltaHeight));
dialog.setLocation(x, y);
}