我有一个从父 shell 创建的自定义 swt shell。我需要设置外壳相对于其父复合材料的位置。但是,因为我在 shell 上调用 setLocation(x, y),所以 setLocation(x,y) 现在相对于 clientArea 起作用。有没有办法让 shell.setLocation(x,y) 相对于 PARENT 复合而不是 clientArea 工作?. 即,即使父复合材料在屏幕上调整大小/移动,自定义外壳也应始终保留在其父复合材料中。
示例代码片段:
class CustOmShellTest {
customShell = new Shell(parent.getShell(), SWT.TOOL | SWT.CLOSE);
customShell.setLayout(new GridLayout());
customShell.setBackgroundMode(SWT.INHERIT_FORCE);
customShell.setSize(300, 400);
customShell.setLocation(parent.getBounds().x, parent.getBounds().y );
}
new CustOmShellTest(parentOfThisInstanceComposite);
//这是相对于 disPlay 定位的实例。我希望它相对于//相对于 parentOfThisInstanceComposite 进行定位
任何帮助表示赞赏!谢谢。