RCP/SWT & JFACE

rcp dialog 화면 가운데 출력

반응형

 public Point getCenterPoint() {
                Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                Rectangle shellBounds = parentShell.getBounds();
                return new Point(shellBounds.x + shellBounds.width / 2, (shellBounds.y + shellBounds.height) / 2);
        }

Then simply override the getInitialLocation method of Dialog;

        @Override
        protected Point getInitialLocation(Point initialSize) {
                Point shellCenter = getCenterPoint();
                return new Point(shellCenter.x - initialSize.x / 2, shellCenter.y - initialSize.y / 2);
        }

 

출처: <https://sureshkrishna.wordpress.com/2007/09/05/make-your-eclipse-dialogs-and-messages-to-cetre-of-screen/

반응형