List of usage examples for org.eclipse.swt.custom ScrolledComposite setMinSize
public void setMinSize(int width, int height)
From source file:ScrolledCompositeMiniSize.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SashForm Test"); shell.setLayout(new FillLayout()); // Create the ScrolledComposite to scroll horizontally and vertically ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite child = new Composite(sc, SWT.NONE); child.setLayout(new FillLayout()); new Button(child, SWT.PUSH).setText("One"); new Button(child, SWT.PUSH).setText("Two"); sc.setMinSize(400, 400); // Expand both horizontally and vertically sc.setExpandHorizontal(true);//from ww w .ja va 2 s . com sc.setExpandVertical(true); sc.setContent(child); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet5.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 5"); shell.setLayout(new FillLayout()); // this button is always 400 x 400. Scrollbars appear if the window is resized to be // too small to show part of the button ScrolledComposite c1 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Button b1 = new Button(c1, SWT.PUSH); b1.setText("fixed size button"); b1.setSize(400, 400);/* ww w . j a va 2s . com*/ c1.setContent(b1); // this button has a minimum size of 400 x 400. If the window is resized to be big // enough to show more than 400 x 400, the button will grow in size. If the window // is made too small to show 400 x 400, scrollbars will appear. ScrolledComposite c2 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Button b2 = new Button(c2, SWT.PUSH); b2.setText("expanding button"); c2.setContent(b2); c2.setExpandHorizontal(true); c2.setExpandVertical(true); c2.setMinSize(400, 400); shell.setSize(600, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { final Display d = new Display(); final Shell shell = new Shell(d); shell.setSize(250, 200);/* w w w.j ava2 s . co m*/ shell.setLayout(new FillLayout()); ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite child = new Composite(sc, SWT.NONE); child.setLayout(new FillLayout()); new Button(child, SWT.PUSH).setText("One"); new Button(child, SWT.PUSH).setText("Two"); sc.setContent(child); sc.setMinSize(300, 300); sc.setExpandHorizontal(true); sc.setExpandVertical(true); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:ScrolledCompositeTest.java
private void createContents(Composite parent) { parent.setLayout(new FillLayout()); // Create the ScrolledComposite to scroll horizontally and vertically ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); // Create a child composite to hold the controls Composite child = new Composite(sc, SWT.NONE); child.setLayout(new FillLayout()); // Create the buttons new Button(child, SWT.PUSH).setText("One"); new Button(child, SWT.PUSH).setText("Two"); /*/*from w ww . j a v a 2 s . c o m*/ * // Set the absolute size of the child child.setSize(400, 400); */ // Set the child as the scrolled content of the ScrolledComposite sc.setContent(child); // Set the minimum size sc.setMinSize(400, 400); // Expand both horizontally and vertically sc.setExpandHorizontal(true); sc.setExpandVertical(true); }
From source file:org.locationtech.udig.processingtoolbox.tools.ScatterPlotDialog.java
private void createInputTab(final CTabFolder parentTabFolder) { inputTab = new CTabItem(parentTabFolder, SWT.NONE); inputTab.setText(Messages.ProcessExecutionDialog_tabparameters); ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL); scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite container = new Composite(scroller, SWT.NONE); container.setLayout(new GridLayout(1, false)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // local moran's i Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$ uiBuilder.createLabel(container, Messages.ScatterPlotDialog_InputLayer, EMPTY, image, 1); cboLayer = uiBuilder.createCombo(container, 1, true); fillLayers(map, cboLayer, VectorLayerType.ALL); uiBuilder.createLabel(container, Messages.ScatterPlotDialog_IndependentField, EMPTY, image, 1); cboXField = uiBuilder.createCombo(container, 1, true); uiBuilder.createLabel(container, Messages.ScatterPlotDialog_DependentField, EMPTY, image, 1); cboYField = uiBuilder.createCombo(container, 1, true); uiBuilder.createLabel(container, null, null, 1); chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 1); chkPearson = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_Pearson, null, 1); // register events cboLayer.addModifyListener(new ModifyListener() { @Override//from www.j av a 2 s . co m public void modifyText(ModifyEvent e) { inputLayer = MapUtils.getLayer(map, cboLayer.getText()); if (inputLayer != null) { fillFields(cboXField, inputLayer.getSchema(), FieldType.Number); fillFields(cboYField, inputLayer.getSchema(), FieldType.Number); } } }); // finally scroller.setContent(container); inputTab.setControl(scroller); scroller.setMinSize(450, container.getSize().y - 2); scroller.setExpandVertical(true); scroller.setExpandHorizontal(true); scroller.pack(); container.pack(); }
From source file:org.locationtech.udig.processingtoolbox.tools.BubbleChartDialog.java
private void createInputTab(final CTabFolder parentTabFolder) { inputTab = new CTabItem(parentTabFolder, SWT.NONE); inputTab.setText(Messages.ProcessExecutionDialog_tabparameters); ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL); scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite container = new Composite(scroller, SWT.NONE); container.setLayout(new GridLayout(1, false)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // local moran's i Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$ uiBuilder.createLabel(container, Messages.ScatterPlotDialog_InputLayer, EMPTY, image, 1); cboLayer = uiBuilder.createCombo(container, 1, true); fillLayers(map, cboLayer, VectorLayerType.ALL); uiBuilder.createLabel(container, Messages.BubbleChartDialog_XField, EMPTY, image, 1); cboXField = uiBuilder.createCombo(container, 1, true); uiBuilder.createLabel(container, Messages.BubbleChartDialog_YField, EMPTY, image, 1); cboYField = uiBuilder.createCombo(container, 1, true); uiBuilder.createLabel(container, Messages.BubbleChartDialog_SizeField, EMPTY, image, 1); cboSize = uiBuilder.createCombo(container, 1, true); uiBuilder.createLabel(container, null, null, 1); chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 1); // register events cboLayer.addModifyListener(new ModifyListener() { @Override/* w w w. j ava 2 s . c o m*/ public void modifyText(ModifyEvent e) { inputLayer = MapUtils.getLayer(map, cboLayer.getText()); if (inputLayer != null) { fillFields(cboXField, inputLayer.getSchema(), FieldType.Number); fillFields(cboYField, inputLayer.getSchema(), FieldType.Number); fillFields(cboSize, inputLayer.getSchema(), FieldType.Number); } } }); // finally scroller.setContent(container); inputTab.setControl(scroller); scroller.setMinSize(450, container.getSize().y - 2); scroller.setExpandVertical(true); scroller.setExpandHorizontal(true); scroller.pack(); container.pack(); }
From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java
private void createInputTab(final CTabFolder parentTabFolder) { inputTab = new CTabItem(parentTabFolder, SWT.NONE); inputTab.setText(Messages.ProcessExecutionDialog_tabparameters); ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL); scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite container = new Composite(scroller, SWT.NONE); container.setLayout(new GridLayout(1, false)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // local moran's i Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$ uiBuilder.createLabel(container, Messages.ScatterPlotDialog_InputLayer, EMPTY, image, 1); cboLayer = uiBuilder.createCombo(container, 1, true); fillLayers(map, cboLayer, VectorLayerType.ALL); uiBuilder.createLabel(container, Messages.BoxPlotDialog_Fields, EMPTY, image, 1); schemaTable = uiBuilder.createTable(container, new String[] { Messages.General_Name }, 1); schemaTable.addSelectionListener(new SelectionAdapter() { @Override//from w ww .java2s.c o m public void widgetSelected(SelectionEvent event) { StringBuffer buffer = new StringBuffer(); for (TableItem item : schemaTable.getItems()) { if (item.getChecked()) { if (buffer.length() > 0) { buffer.append(",").append(item.getText()); //$NON-NLS-1$ } else { buffer.append(item.getText()); } } } selectedFields = buffer.toString(); } }); uiBuilder.createLabel(container, null, null, 1); chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 1); // register events cboLayer.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { schemaTable.removeAll(); inputLayer = MapUtils.getLayer(map, cboLayer.getText()); if (inputLayer != null) { for (AttributeDescriptor dsc : inputLayer.getSchema().getAttributeDescriptors()) { Class<?> binding = dsc.getType().getBinding(); if (Number.class.isAssignableFrom(binding)) { TableItem item = new TableItem(schemaTable, SWT.NULL); item.setText(dsc.getLocalName()); } } } } }); // finally scroller.setContent(container); inputTab.setControl(scroller); scroller.setMinSize(450, container.getSize().y - 2); scroller.setExpandVertical(true); scroller.setExpandHorizontal(true); scroller.pack(); container.pack(); }
From source file:org.locationtech.udig.processingtoolbox.tools.HistogramDialog.java
private void createInputTab(final CTabFolder parentTabFolder) { inputTab = new CTabItem(parentTabFolder, SWT.NONE); inputTab.setText(Messages.ProcessExecutionDialog_tabparameters); ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL); scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite container = new Composite(scroller, SWT.NONE); container.setLayout(new GridLayout(2, false)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // local moran's i Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$ uiBuilder.createLabel(container, Messages.HistogramDialog_InputLayer, EMPTY, image, 2); cboLayer = uiBuilder.createCombo(container, 2, true); fillLayers(map, cboLayer, VectorLayerType.ALL); uiBuilder.createLabel(container, Messages.HistogramDialog_InputField, EMPTY, image, 2); cboField = uiBuilder.createCombo(container, 2, true); uiBuilder.createLabel(container, Messages.HistogramDialog_BinCount, EMPTY, image, 2); spinner = uiBuilder.createSpinner(container, 10, 1, 50, 0, 1, 5, 2); // yXais Type uiBuilder.createLabel(container, Messages.HistogramDialog_YAxisType, EMPTY, image, 1); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0;//from w ww . ja v a 2 s . c o m Composite subCon = new Composite(container, SWT.NONE); subCon.setLayout(layout); subCon.setLayoutData(new GridData(SWT.LEFT_TO_RIGHT, SWT.CENTER, false, false, 1, 1)); final Button chkRatio = uiBuilder.createRadioButton(subCon, Messages.HistogramDialog_Ratio, null, 1); final Button chkFrequency = uiBuilder.createRadioButton(subCon, Messages.HistogramDialog_Frequency, null, 1); chkFrequency.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { if (chkFrequency.getSelection()) { histogramType = HistogramType.FREQUENCY; } } }); chkRatio.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { if (chkRatio.getSelection()) { histogramType = HistogramType.RELATIVE_FREQUENCY; } } }); chkRatio.setSelection(true); uiBuilder.createLabel(container, null, null, 2); chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 2); // register events cboLayer.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { inputLayer = MapUtils.getLayer(map, cboLayer.getText()); if (inputLayer != null) { fillFields(cboField, inputLayer.getSchema(), FieldType.Number); } } }); // finally scroller.setContent(container); inputTab.setControl(scroller); scroller.setMinSize(450, container.getSize().y - 2); scroller.setExpandVertical(true); scroller.setExpandHorizontal(true); scroller.pack(); container.pack(); }
From source file:org.locationtech.udig.processingtoolbox.tools.MoranScatterPlotDialog.java
private void createInputTab(final CTabFolder parentTabFolder) { inputTab = new CTabItem(parentTabFolder, SWT.NONE); inputTab.setText(Messages.ProcessExecutionDialog_tabparameters); ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL); scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite container = new Composite(scroller, SWT.NONE); container.setLayout(new GridLayout(1, false)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // local moran's i Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$ uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_InputLayer, EMPTY, image, 1); cboLayer = uiBuilder.createCombo(container, 1, true); fillLayers(map, cboLayer, VectorLayerType.ALL); uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_InputField, EMPTY, image, 1); cboField = uiBuilder.createCombo(container, 1, true); uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_Conceptualization, EMPTY, 1); cboConcept = uiBuilder.createCombo(container, 1, true); cboConcept.addModifyListener(new ModifyListener() { @Override/* w w w .j a v a2s . c o m*/ public void modifyText(ModifyEvent e) { for (Object enumVal : SpatialConcept.class.getEnumConstants()) { if (enumVal.toString().equalsIgnoreCase(cboConcept.getText())) { params.put(GlobalMoransIProcessFactory.spatialConcept.key, enumVal); break; } } } }); fillEnum(cboConcept, SpatialConcept.class); uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_DistanceMethod, EMPTY, 1); cboDistance = uiBuilder.createCombo(container, 1, true); cboDistance.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { for (Object enumVal : DistanceMethod.class.getEnumConstants()) { if (enumVal.toString().equalsIgnoreCase(cboDistance.getText())) { params.put(GlobalMoransIProcessFactory.distanceMethod.key, enumVal); break; } } } }); fillEnum(cboDistance, DistanceMethod.class); uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_Standardization, EMPTY, 1); cboStandard = uiBuilder.createCombo(container, 1, true); cboStandard.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { for (Object enumVal : StandardizationMethod.class.getEnumConstants()) { if (enumVal.toString().equalsIgnoreCase(cboStandard.getText())) { params.put(GlobalMoransIProcessFactory.standardization.key, enumVal); break; } } } }); fillEnum(cboStandard, StandardizationMethod.class); uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_DistanceBand, EMPTY, 1); final Text txtDistance = uiBuilder.createText(container, EMPTY, 1, true); txtDistance.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { Object obj = Converters.convert(txtDistance.getText(), Double.class); if (obj == null) { params.put(GlobalMoransIProcessFactory.searchDistance.key, Double.valueOf(0d)); } else { params.put(GlobalMoransIProcessFactory.searchDistance.key, obj); } } }); // register events cboLayer.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { inputLayer = MapUtils.getLayer(map, cboLayer.getText()); if (inputLayer == null) { return; } SimpleFeatureCollection features = MapUtils.getFeatures(inputLayer); params.put(GlobalMoransIProcessFactory.inputFeatures.key, features); fillFields(cboField, inputLayer.getSchema(), FieldType.Number); } }); cboField.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { params.put(GlobalMoransIProcessFactory.inputField.key, cboField.getText()); } }); // finally scroller.setContent(container); inputTab.setControl(scroller); scroller.setMinSize(450, container.getSize().y - 2); scroller.setExpandVertical(true); scroller.setExpandHorizontal(true); scroller.pack(); container.pack(); }