*/
public static void centerAndShow(Window win) {
Dimension wD = win.getSize();
Dimension frameD;
Point framePos;
Frame frame = JOptionPane.getFrameForComponent(win);
// Should this window be centered to its parent frame?
boolean centerToParentFrame = (frame != null) && (frame != win)
&& frame.isShowing();
// Center to parent frame or to screen
if (centerToParentFrame) {
frameD = frame.getSize();
framePos = frame.getLocation();
} else {
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
// dual head, use first screen
if (ge.getScreenDevices().length > 1) {