import org.eclipse.swt.SWT; import org.eclipse.swt.custom.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class ShellON_TOP { static boolean activated = false; static Shell resizableShell; static final int DRAG_TOLERANCE = 4; public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(); shell.setBounds(10, 10, 200, 200); final StyledText text = new StyledText(shell,SWT.BORDER); text.setBounds(10,10,140,140); text.addListener(SWT.KeyDown, new Listener() { public void handleEvent(Event event) { if (!activated) { activated = true; resizableShell = new Shell(shell, SWT.ON_TOP); resizableShell.addListener(SWT.MouseMove, new Listener() { public void handleEvent(Event event) { if ((event.stateMask & SWT.BUTTON1) != 0) { Display display = resizableShell.getDisplay(); Rectangle bounds = resizableShell.getBounds(); int edgeStyle = SWT.NONE; if (bounds.width - event.x < DRAG_TOLERANCE) edgeStyle |= SWT.RIGHT; if (bounds.height - event.y < DRAG_TOLERANCE) edgeStyle |= SWT.DOWN; if (event.x < DRAG_TOLERANCE) edgeStyle |= SWT.LEFT; if (event.y < DRAG_TOLERANCE) edgeStyle |= SWT.UP; if (edgeStyle != SWT.NONE) { Tracker tracker = new Tracker(display,edgeStyle | SWT.RESIZE); tracker.setRectangles(new Rectangle[] {bounds}); if (!tracker.open()) return; // cancelled resizableShell.setBounds(tracker.getRectangles()[0]); } } } }); resizableShell.setBounds(60,60,100,100); Table table = new Table(resizableShell, SWT.BORDER); for (int i = 0; i < 3; i++) { new TableItem(table,SWT.NONE).setText("aaa"); } table.setBounds(10,10,50,50); resizableShell.setVisible(true); resizableShell.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { activated = false; } }); } } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } }