如果主窗口的大小和位置可以调整,可以在主窗口的中心打开对话框吗?

时间:2015-08-20 17:39:19

标签: java swt jface

shell = new Shell(getParent(), getStyle());
shell.setText("Key Information");
Shell primary = Display.getCurrent().getActiveShell();
Rectangle bounds = primary.getBounds();
Rectangle rect = Display.getCurrent().getActiveShell().getBounds();
int x = bounds.x + (bounds.width - rect.width) / 2;
int y = bounds.y + (bounds.height - rect.height) / 2;
shell.setLocation(x + 350, y + 100);
createContents();
shell.pack();
shell.open();
  1. 如上面的代码给出了对话框的近似中心位置。如果我改变主窗口对话框的大小或位置没有到达中心位置.open()给出对话框的详细信息。
  2. 当主窗口位置移动到角落对话框时,只能在监视器内打开。

0 个答案:

没有答案