views:

30

answers:

1

I've created the most basic JFace ApplicationWindow I can think of and I get this 1 pixel white border at the top of the screen:

alt text

And the code to create it:

import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.SWT;

public class TestWindow extends ApplicationWindow {
    public TestWindow() {
        super(null);
    }

    protected Control createContents(Composite parent) {
        this.getShell().setText("Test Window");

        parent.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_GREEN));
        return parent;
    }
}

As I add additional Composite controls to the window, the gap gets even bigger. What can I do to get rid of it?

+2  A: 

You can try to override the function:

protected boolean showTopSeperator() {
    return false;
}
qrtt1
If I do that, it does remove the line. However, as soon as I add a `Composite` to the shell, the line reappears.
jasonh
Well, it looks like the problem is internal to `ApplicationWindow`. If you look at ApplicationWindow.java, you'll see an internal `ApplicationWindowLayout` class that has `static final int VGAP = 2;` which is added to the `y` position of every top-level control I add, thus adding a non-sensical white line to the top of the shell.I wonder, how does Eclipse itself avoid this white line from showing up?
jasonh