package org.eclipse.swt.snippets; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; public class SnippetGrip { public static void main(String[] args) { final Display display= new Display(); final Shell shell= new Shell(display, SWT.RESIZE); GridLayout shellLayout= new GridLayout(2, false); shellLayout.marginWidth= 0; shellLayout.marginHeight= 0; shell.setLayout(shellLayout); Composite content= new Composite(shell, SWT.BORDER); content.setBackground(display.getSystemColor(SWT.COLOR_DARK_MAGENTA)); content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite resizer= new Composite(shell, SWT.H_SCROLL | SWT.V_SCROLL); GridData gd= new GridData(SWT.END, SWT.END, false, false); gd.heightHint= gd.widthHint= 0; // set to 42 and it's fine resizer.setLayoutData(gd); display.addFilter(SWT.KeyDown, new Listener() { public void handleEvent(Event event) { if (event.character == SWT.ESC) shell.dispose(); } }); shell.setBounds(200, 200, 200, 140); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }