Search code examples
javashellscrollswttitlebar

Java SWT - shell's titlebar disappear when using SWT.V_SCROLL on shell


Well, I'm not sure if I'm doing something wrong, but when I use SWT.V_SCROLL on shell, its titlebar disappears. In addition, shell window cannot be resized or moved. I'm using Windows 8.1, Eclipse 4.4 and SWT 4.4 (all are x64 versions).

    final private static Shell shell = new Shell(SWT.V_SCROLL);

    //shell init
    shell.setSize(850, 900);
    shell.setLocation(200, 10);
    Rectangle shellSize = shell.getBounds();
    shell.setMinimumSize(shellSize.width, shellSize.height);

    FormLayout layout_shell = new FormLayout();
    shell.setLayout(layout_shell);

This is how it looks like:

http://snag.gy/OzfNv.jpg

When used 'clean' shell:

    final private static Shell shell = new Shell();

http://snag.gy/mEuK2.jpg

Thanks in advance for help!


Solution

  • If you call new Shell(SWT.V_SCROLL), the generated shell will only be able to scroll and won't have any decorations and/or resize/move functionality. The default constructor (without parameter) on the other hand internally calls other constructors and sets the style to SHELL_TRIM.

    If you want your application to be scrollable, add a ScrolledComposite as the first child of your Shell.


    Note: using new Shell(SWT.SHELL_TRIM | SWT.V_SCROLL) does show a scrollbar, but the content won't actually scroll