1

这是一种奇怪的行为,没有图片很难解释,所以我会尽力而为。

我的应用程序有一个嵌入式 SWT 浏览器小部件,并且该应用程序是跨平台的。它在 Windows 上完美运行,但需要支持 Mac OS X 10.4 及更高版本。浏览器小部件位于右侧的组合中,而另一个组合中的文件树位于左侧。用户从树中单击文件,它们依次被解密并显示在浏览器中。

我目前正在 Mac 10.4.11 上测试该应用程序,这种奇怪的行为仅在我调整 shell 窗口大小时才会发生。复合和浏览器小部件本身会正确调整大小。我可以看到对象的边界/边界。问题是应该在浏览器中的图像 - 移位(几乎就像显示的图像没有锚定到浏览器的左上角一样)。它从上到下对齐,并且图像本身的大小是正确的,但是在调整大小完成后图像会移动。该应用程序在最初加载时看起来很好(意味着图像对齐完美),当文件树被隐藏并且浏览器/复合占用完整的外壳时看​​起来很好,当文件树恢复时看起来很好。只有在调整大小时才会发生这种情况。

我希望这有点道理。有任何想法吗?

4

1 回答 1

3

Ok i figured it out. Here is what I had at first (in pseudo-code):

webBrowser.setSize(shell.width, shell.height);

webComposite.getParent().layout();

Turns out i needed to pretty much restore the browser and its composite in the same way i did when i restored the file tree (cause i knew it was correctly sized after that action). The code above was replaced with:

webComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));

webComposite.setBounds(widthOfTreeComposite, 0, shell.width, shell.height);

webComposite.setSize(shell.width, shell.height);

webBrowser.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));

webBrowser.setBounds(0, 0, shell.width, shell.height);

于 2009-05-29T15:17:43.103 回答