List of usage examples for org.eclipse.swt.widgets Composite computeSize
public Point computeSize(int wHint, int hHint)
From source file:GraphicsExample.java
void createToolBar(final Composite parent) { final Display display = parent.getDisplay(); toolBar = new ToolBar(parent, SWT.FLAT); Listener toolBarListener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.Selection: { if (event.widget == playItem) { animate = true;//from ww w . j ava 2 s.c o m playItem.setEnabled(!animate); pauseItem.setEnabled(animate); } else if (event.widget == pauseItem) { animate = false; playItem.setEnabled(!animate); pauseItem.setEnabled(animate); } else if (event.widget == backItem) { final ToolItem toolItem = (ToolItem) event.widget; final ToolBar toolBar = toolItem.getParent(); Rectangle toolItemBounds = toolItem.getBounds(); Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y)); backMenu.setLocation(point.x, point.y + toolItemBounds.height); backMenu.setVisible(true); } } break; } } }; playItem = new ToolItem(toolBar, SWT.PUSH); playItem.setText(getResourceString("Play")); //$NON-NLS-1$ playItem.setImage(loadImage(display, "play.gif")); //$NON-NLS-1$ playItem.addListener(SWT.Selection, toolBarListener); pauseItem = new ToolItem(toolBar, SWT.PUSH); pauseItem.setText(getResourceString("Pause")); //$NON-NLS-1$ pauseItem.setImage(loadImage(display, "pause.gif")); //$NON-NLS-1$ pauseItem.addListener(SWT.Selection, toolBarListener); backItem = new ToolItem(toolBar, SWT.PUSH); backItem.setText(getResourceString("Background")); //$NON-NLS-1$ backItem.addListener(SWT.Selection, toolBarListener); String[] names = new String[] { getResourceString("White"), //$NON-NLS-1$ getResourceString("Black"), //$NON-NLS-1$ getResourceString("Red"), //$NON-NLS-1$ getResourceString("Green"), //$NON-NLS-1$ getResourceString("Blue"), //$NON-NLS-1$ getResourceString("CustomColor"), //$NON-NLS-1$ }; Color[] colors = new Color[] { display.getSystemColor(SWT.COLOR_WHITE), display.getSystemColor(SWT.COLOR_BLACK), display.getSystemColor(SWT.COLOR_RED), display.getSystemColor(SWT.COLOR_GREEN), display.getSystemColor(SWT.COLOR_BLUE), null, }; backMenu = new Menu(parent); Listener listener = new Listener() { public void handleEvent(Event event) { MenuItem item = (MenuItem) event.widget; if (customMI == item) { ColorDialog dialog = new ColorDialog(parent.getShell()); RGB rgb = dialog.open(); if (rgb == null) return; if (customColor != null) customColor.dispose(); customColor = new Color(display, rgb); if (customImage != null) customImage.dispose(); customImage = createImage(display, customColor); item.setData(new Object[] { customColor, customImage }); item.setImage(customImage); } tabBackground = (Object[]) item.getData(); backItem.setImage((Image) tabBackground[1]); canvas.redraw(); } }; for (int i = 0; i < names.length; i++) { MenuItem item = new MenuItem(backMenu, SWT.NONE); item.setText(names[i]); item.addListener(SWT.Selection, listener); Image image = null; if (colors[i] != null) { image = createImage(display, colors[i]); images.addElement(image); item.setImage(image); } else { // custom menu item customMI = item; } item.setData(new Object[] { colors[i], image }); if (tabBackground == null) { tabBackground = (Object[]) item.getData(); backItem.setImage((Image) tabBackground[1]); } } dbItem = new ToolItem(toolBar, SWT.CHECK); dbItem.setText(getResourceString("DoubleBuffer")); //$NON-NLS-1$ dbItem.setImage(loadImage(display, "db.gif")); //$NON-NLS-1$ ToolItem separator = new ToolItem(toolBar, SWT.SEPARATOR); Composite comp = new Composite(toolBar, SWT.NONE); GridData data; GridLayout layout = new GridLayout(1, false); layout.verticalSpacing = 0; layout.marginWidth = layout.marginHeight = 3; comp.setLayout(layout); timerSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP); data = new GridData(SWT.CENTER, SWT.CENTER, false, false); timerSpinner.setLayoutData(data); Label label = new Label(comp, SWT.NONE); label.setText(getResourceString("Animation")); //$NON-NLS-1$ data = new GridData(SWT.CENTER, SWT.CENTER, false, false); label.setLayoutData(data); timerSpinner.setMaximum(1000); timerSpinner.setSelection(TIMER); timerSpinner.setSelection(TIMER); separator.setControl(comp); separator.setWidth(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); }
From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java
private void initPreferencesGroup(Composite parent) { GridData gridData = new GridData(); gridData.horizontalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; Group group = new Group(parent, SWT.SHADOW_ETCHED_IN); GridLayout layout = new GridLayout(1, false); group.setLayoutData(gridData);/* w w w . java 2 s . c o m*/ group.setLayout(layout); group.setText("Preferences"); final ScrolledComposite scrolled = new ScrolledComposite(group, SWT.H_SCROLL); scrolled.setLayoutData(new GridData(GridData.FILL_BOTH)); final Composite preferencesComposite = UIUtils.createScrolledBody(scrolled, SWT.NONE); preferencesComposite.setLayout(new GridLayout(6, false)); scrolled.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(Event e) { scrolled.setMinSize(preferencesComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } }); scrolled.setAlwaysShowScrollBars(true); scrolled.setContent(preferencesComposite); scrolled.setMinSize(preferencesComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(true); liveConstraints = new Button(preferencesComposite, SWT.TOGGLE); liveConstraints.setText("Auto-Recalc of Constraints"); liveConstraints.setEnabled(false); liveConstraints .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER)); recalculate = new Button(preferencesComposite, SWT.DEFAULT); recalculate.setText("Calculate Solution"); recalculate.setEnabled(false); recalculate.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (activeSolver != null) { // ok - make sure the performance tab is open graphTabs.setSelection(performanceTab); activeSolver.run(true, true); main.setSize(0, 0); main.getParent().layout(true, true); } } }); recalculate.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_CENTER)); cancelGeneration = new Button(preferencesComposite, SWT.PUSH); cancelGeneration.setText("Cancel"); cancelGeneration.setVisible(false); cancelGeneration.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (activeSolver != null) { activeSolver.cancel(); } } }); suppressCuts = new Button(preferencesComposite, SWT.CHECK); suppressCuts.setText("Suppress Cuts"); suppressCuts.setVisible(true); suppressCuts.setEnabled(false); suppressCuts.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (activeSolver != null) { boolean doSuppress = suppressCuts.getSelection(); activeSolver.setAutoSuppress(doSuppress); } } }); showOSCourse = new Button(preferencesComposite, SWT.CHECK); showOSCourse.setText("Plot O/S Course"); showOSCourse.setVisible(true); showOSCourse.setEnabled(false); showOSCourse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (activeSolver != null) { redoOwnshipStates(); } } }); Composite precisionPanel = new Composite(preferencesComposite, SWT.NONE); precisionPanel.setLayoutData(new GridData( GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER)); GridLayout precisionLayout = new GridLayout(2, false); precisionLayout.horizontalSpacing = 5; precisionPanel.setLayout(precisionLayout); Label precisionLabel = new Label(precisionPanel, SWT.NONE); precisionLabel.setText("Precision:"); precisionLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); precisionsCombo = new ComboViewer(precisionPanel); precisionsCombo.getCombo().setEnabled(false); precisionsCombo.setContentProvider(new ArrayContentProvider()); precisionsCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((Precision) element).getLabel(); } }); precisionsCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection sel = precisionsCombo.getSelection(); IStructuredSelection cSel = (IStructuredSelection) sel; Precision precision = (Precision) cSel.getFirstElement(); if (activeSolver != null) { activeSolver.setPrecision(precision); } } }); }
From source file:ClipboardExample.java
public void open(Display display) { clipboard = new Clipboard(display); shell = new Shell(display); shell.setText("SWT Clipboard"); shell.setLayout(new FillLayout()); ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite parent = new Composite(sc, SWT.NONE); sc.setContent(parent);/*from w ww. ja v a 2 s . c om*/ parent.setLayout(new GridLayout(2, true)); Group copyGroup = new Group(parent, SWT.NONE); copyGroup.setText("Copy From:"); GridData data = new GridData(GridData.FILL_BOTH); copyGroup.setLayoutData(data); copyGroup.setLayout(new GridLayout(3, false)); Group pasteGroup = new Group(parent, SWT.NONE); pasteGroup.setText("Paste To:"); data = new GridData(GridData.FILL_BOTH); pasteGroup.setLayoutData(data); pasteGroup.setLayout(new GridLayout(3, false)); Group controlGroup = new Group(parent, SWT.NONE); controlGroup.setText("Control API:"); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; controlGroup.setLayoutData(data); controlGroup.setLayout(new GridLayout(5, false)); Group typesGroup = new Group(parent, SWT.NONE); typesGroup.setText("Available Types"); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; typesGroup.setLayoutData(data); typesGroup.setLayout(new GridLayout(2, false)); status = new Label(parent, SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; data.heightHint = 60; status.setLayoutData(data); createTextTransfer(copyGroup, pasteGroup); createRTFTransfer(copyGroup, pasteGroup); createHTMLTransfer(copyGroup, pasteGroup); createFileTransfer(copyGroup, pasteGroup); createMyTransfer(copyGroup, pasteGroup); createControlTransfer(controlGroup); createAvailableTypes(typesGroup); sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setExpandHorizontal(true); sc.setExpandVertical(true); Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle monitorArea = shell.getMonitor().getClientArea(); shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } clipboard.dispose(); }
From source file:org.eclipse.swt.examples.clipboard.ClipboardExample.java
public void open(Display display) { clipboard = new Clipboard(display); shell = new Shell(display); shell.setText("SWT Clipboard"); shell.setLayout(new FillLayout()); ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite parent = new Composite(sc, SWT.NONE); sc.setContent(parent);//from www . j a v a 2 s. c o m parent.setLayout(new GridLayout(2, true)); Group copyGroup = new Group(parent, SWT.NONE); copyGroup.setText("Copy From:"); GridData data = new GridData(GridData.FILL_BOTH); copyGroup.setLayoutData(data); copyGroup.setLayout(new GridLayout(3, false)); Group pasteGroup = new Group(parent, SWT.NONE); pasteGroup.setText("Paste To:"); data = new GridData(GridData.FILL_BOTH); pasteGroup.setLayoutData(data); pasteGroup.setLayout(new GridLayout(3, false)); Group controlGroup = new Group(parent, SWT.NONE); controlGroup.setText("Control API:"); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; controlGroup.setLayoutData(data); controlGroup.setLayout(new GridLayout(5, false)); Group typesGroup = new Group(parent, SWT.NONE); typesGroup.setText("Available Types"); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; typesGroup.setLayoutData(data); typesGroup.setLayout(new GridLayout(2, false)); status = new Label(parent, SWT.NONE); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; status.setLayoutData(data); createTextTransfer(copyGroup, pasteGroup); createRTFTransfer(copyGroup, pasteGroup); createHTMLTransfer(copyGroup, pasteGroup); createFileTransfer(copyGroup, pasteGroup); createImageTransfer(copyGroup, pasteGroup); createMyTransfer(copyGroup, pasteGroup); createControlTransfer(controlGroup); createAvailableTypes(typesGroup); sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setExpandHorizontal(true); sc.setExpandVertical(true); Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle monitorArea = shell.getMonitor().getClientArea(); shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } clipboard.dispose(); }
From source file:org.eclipse.swt.examples.dnd.DNDExample.java
public void open(Display display) { Shell shell = new Shell(display); shell.setText("Drag and Drop Example"); shell.setLayout(new FillLayout()); itemImage = new Image(display, DNDExample.class.getResourceAsStream("openFolder.gif")); ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite parent = new Composite(sc, SWT.NONE); sc.setContent(parent);/*from w ww . j ava2 s. com*/ parent.setLayout(new FormLayout()); Label dragLabel = new Label(parent, SWT.LEFT); dragLabel.setText("Drag Source:"); Group dragWidgetGroup = new Group(parent, SWT.NONE); dragWidgetGroup.setText("Widget"); createDragWidget(dragWidgetGroup); Composite cLeft = new Composite(parent, SWT.NONE); cLeft.setLayout(new GridLayout(2, false)); Group dragOperationsGroup = new Group(cLeft, SWT.NONE); dragOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); dragOperationsGroup.setText("Allowed Operation(s):"); createDragOperations(dragOperationsGroup); Group dragTypesGroup = new Group(cLeft, SWT.NONE); dragTypesGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); dragTypesGroup.setText("Transfer Type(s):"); createDragTypes(dragTypesGroup); dragConsole = new Text(cLeft, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); dragConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Menu menu = new Menu(shell, SWT.POP_UP); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("Clear"); item.addSelectionListener(widgetSelectedAdapter(e -> dragConsole.setText(""))); item = new MenuItem(menu, SWT.CHECK); item.setText("Show Event detail"); item.addSelectionListener(widgetSelectedAdapter(e -> { MenuItem eItem = (MenuItem) e.widget; dragEventDetail = eItem.getSelection(); })); dragConsole.setMenu(menu); Label dropLabel = new Label(parent, SWT.LEFT); dropLabel.setText("Drop Target:"); Group dropWidgetGroup = new Group(parent, SWT.NONE); dropWidgetGroup.setText("Widget"); createDropWidget(dropWidgetGroup); Composite cRight = new Composite(parent, SWT.NONE); cRight.setLayout(new GridLayout(2, false)); Group dropOperationsGroup = new Group(cRight, SWT.NONE); dropOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 2)); dropOperationsGroup.setText("Allowed Operation(s):"); createDropOperations(dropOperationsGroup); Group dropTypesGroup = new Group(cRight, SWT.NONE); dropTypesGroup.setText("Transfer Type(s):"); createDropTypes(dropTypesGroup); Group feedbackTypesGroup = new Group(cRight, SWT.NONE); feedbackTypesGroup.setText("Feedback Type(s):"); createFeedbackTypes(feedbackTypesGroup); dropConsole = new Text(cRight, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); dropConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); menu = new Menu(shell, SWT.POP_UP); item = new MenuItem(menu, SWT.PUSH); item.setText("Clear"); item.addSelectionListener(widgetSelectedAdapter(e -> dropConsole.setText(""))); item = new MenuItem(menu, SWT.CHECK); item.setText("Show Event detail"); item.addSelectionListener(widgetSelectedAdapter(e -> { MenuItem eItem = (MenuItem) e.widget; dropEventDetail = eItem.getSelection(); })); dropConsole.setMenu(menu); if (dragEnabled) createDragSource(); if (dropEnabled) createDropTarget(); int height = 200; FormData data = new FormData(); data.top = new FormAttachment(0, 10); data.left = new FormAttachment(0, 10); dragLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dragLabel, 10); data.left = new FormAttachment(0, 10); data.right = new FormAttachment(50, -10); data.height = height; dragWidgetGroup.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dragWidgetGroup, 10); data.left = new FormAttachment(0, 10); data.right = new FormAttachment(50, -10); data.bottom = new FormAttachment(100, -10); cLeft.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(0, 10); data.left = new FormAttachment(cLeft, 10); dropLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dropLabel, 10); data.left = new FormAttachment(cLeft, 10); data.right = new FormAttachment(100, -10); data.height = height; dropWidgetGroup.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dropWidgetGroup, 10); data.left = new FormAttachment(cLeft, 10); data.right = new FormAttachment(100, -10); data.bottom = new FormAttachment(100, -10); cRight.setLayoutData(data); sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setExpandHorizontal(true); sc.setExpandVertical(true); Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle monitorArea = shell.getMonitor().getClientArea(); shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } itemImage.dispose(); }
From source file:DNDExample.java
public void open(Display display) { Shell shell = new Shell(display); shell.setText("Drag and Drop Example"); shell.setLayout(new FillLayout()); ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite parent = new Composite(sc, SWT.NONE); sc.setContent(parent);/*from w w w.j av a 2 s . c o m*/ parent.setLayout(new FormLayout()); Label dragLabel = new Label(parent, SWT.LEFT); dragLabel.setText("Drag Source:"); Group dragWidgetGroup = new Group(parent, SWT.NONE); dragWidgetGroup.setText("Widget"); createDragWidget(dragWidgetGroup); Composite cLeft = new Composite(parent, SWT.NONE); cLeft.setLayout(new GridLayout(2, false)); Group dragOperationsGroup = new Group(cLeft, SWT.NONE); dragOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); dragOperationsGroup.setText("Allowed Operation(s):"); createDragOperations(dragOperationsGroup); Group dragTypesGroup = new Group(cLeft, SWT.NONE); dragTypesGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); dragTypesGroup.setText("Transfer Type(s):"); createDragTypes(dragTypesGroup); dragConsole = new Text(cLeft, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); dragConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Menu menu = new Menu(shell, SWT.POP_UP); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("Clear"); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dragConsole.setText(""); } }); item = new MenuItem(menu, SWT.CHECK); item.setText("Show Event detail"); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { MenuItem item = (MenuItem) e.widget; dragEventDetail = item.getSelection(); } }); dragConsole.setMenu(menu); Label dropLabel = new Label(parent, SWT.LEFT); dropLabel.setText("Drop Target:"); Group dropWidgetGroup = new Group(parent, SWT.NONE); dropWidgetGroup.setText("Widget"); createDropWidget(dropWidgetGroup); Composite cRight = new Composite(parent, SWT.NONE); cRight.setLayout(new GridLayout(2, false)); Group dropOperationsGroup = new Group(cRight, SWT.NONE); dropOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 2)); dropOperationsGroup.setText("Allowed Operation(s):"); createDropOperations(dropOperationsGroup); Group dropTypesGroup = new Group(cRight, SWT.NONE); dropTypesGroup.setText("Transfer Type(s):"); createDropTypes(dropTypesGroup); Group feedbackTypesGroup = new Group(cRight, SWT.NONE); feedbackTypesGroup.setText("Feedback Type(s):"); createFeedbackTypes(feedbackTypesGroup); dropConsole = new Text(cRight, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); dropConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); menu = new Menu(shell, SWT.POP_UP); item = new MenuItem(menu, SWT.PUSH); item.setText("Clear"); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dropConsole.setText(""); } }); item = new MenuItem(menu, SWT.CHECK); item.setText("Show Event detail"); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { MenuItem item = (MenuItem) e.widget; dropEventDetail = item.getSelection(); } }); dropConsole.setMenu(menu); int height = 200; FormData data = new FormData(); data.top = new FormAttachment(0, 10); data.left = new FormAttachment(0, 10); dragLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dragLabel, 10); data.left = new FormAttachment(0, 10); data.right = new FormAttachment(50, -10); data.height = height; dragWidgetGroup.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dragWidgetGroup, 10); data.left = new FormAttachment(0, 10); data.right = new FormAttachment(50, -10); data.bottom = new FormAttachment(100, -10); cLeft.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(0, 10); data.left = new FormAttachment(cLeft, 10); dropLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dropLabel, 10); data.left = new FormAttachment(cLeft, 10); data.right = new FormAttachment(100, -10); data.height = height; dropWidgetGroup.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dropWidgetGroup, 10); data.left = new FormAttachment(cLeft, 10); data.right = new FormAttachment(100, -10); data.bottom = new FormAttachment(100, -10); cRight.setLayoutData(data); sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setExpandHorizontal(true); sc.setExpandVertical(true); Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle monitorArea = shell.getMonitor().getClientArea(); shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }