When centering dialog, first appears on topleft corner for some milliseconds
问题 I'm generating a dialog with a lot of content. I want to pack the dialog to the childrens height, and I want to center it on screen, so I'm doing this after adding all the childrens: shell.open(); shell.layout(); shell.pack(); //for wrap the dialog size to it's content width and height. //the dialog must be centered after doing shell.pack(); Rectangle parentSize = getParent().getBounds(); Rectangle shellSize = shell.getBounds(); int x = parentSize.x + (parentSize.width - shellSize.width) / 2;