JFace中WizardDialog默认居中

 WizardDialog 默认弹出不居中,下面是让其居中的代码

  WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), new ScanWizard());
  dlg.setPageSize(560, 320);
  dlg.create();
        //设置窗口自动居中
        Rectangle screenSize = Display.getDefault().getClientArea();
        Shell shell =dlg.getShell();
        shell.setLocation((screenSize.width - dlg.getShell().getBounds().width) / 2,(
                screenSize.height -dlg.getShell().getBounds().height) / 2);
  dlg.open();

原文地址:https://www.cnblogs.com/wuhenke/p/2384085.html