tags:

views:

310

answers:

1

This is a strange behavior, and hard to explain without a picture, so I will try my best.

My application has an embedded SWT browser widget, and the application is cross platform. It works perfect on Windows, but need to support Mac OS X 10.4 and above. The browser widget is within a composite on the right side, and a file tree within another composite is on the left side. The user clicks files from the tree, and they are in turn decrypted and displayed in the browser.

I am testing the app on Mac 10.4.11 currently and this strange behavior happens only when I resize the shell window. The composite and browser widget itself resize properly. I can see the bounds/border of the objects. The problem is the image that is supposed to be within the browser - shifts (almost as if the displayed image is not anchored to the top left corner of the browser). It is aligned top to bottom, and the image itself is the correct size, but the image moves after the resize is done. The app looks fine (meaning the image is aligned perfect) when it initially loads, looks fine when the file tree is hidden and the browser/composite take up the full shell, looks fine when the file tree is restored. It only during resize that this happens.

I hope that made some sense. Any ideas?

+2  A: 

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);