List of usage examples for org.eclipse.swt.widgets Composite Composite
public Composite(Composite parent, int style)
From source file:grafici.PrenotazioniPieChart.java
/** * Default constructor.//w w w . j a va 2s.c o m * * @param title * the frame title. */ public PrenotazioniPieChart(String title, Composite parent, int style, int tipo) { super(parent, style); titolo = title; Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED); GridData gdCmp = new GridData(SWT.FILL); gdCmp.horizontalAlignment = SWT.FILL; gdCmp.verticalAlignment = SWT.FILL; gdCmp.grabExcessHorizontalSpace = true; gdCmp.grabExcessVerticalSpace = true; cmp.setLayoutData(gdCmp); cmp.setLayout(new GridLayout(1, false)); JPanel chartPanel = createDemoPanel(tipo); Frame graphFrame = SWT_AWT.new_Frame(cmp); graphFrame.add(chartPanel); graphFrame.pack(); GridData gdThis = new GridData(SWT.FILL); gdThis.horizontalAlignment = SWT.FILL; gdThis.verticalAlignment = SWT.FILL; gdThis.grabExcessHorizontalSpace = true; gdThis.grabExcessVerticalSpace = true; this.setLayoutData(gdThis); this.setLayout(new GridLayout(1, false)); }
From source file:grafici.MediciPieChart.java
/** * Default constructor./*ww w . j a v a2 s . c o m*/ * * @param title * the frame title. */ public MediciPieChart(String title, Composite parent, int style, int tipo) { super(parent, style); titolo = title; Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED); GridData gdCmp = new GridData(SWT.FILL); gdCmp.horizontalAlignment = SWT.FILL; gdCmp.verticalAlignment = SWT.FILL; gdCmp.grabExcessHorizontalSpace = true; gdCmp.grabExcessVerticalSpace = true; cmp.setLayoutData(gdCmp); cmp.setLayout(new GridLayout(1, false)); JPanel chartPanel = createDemoPanel(tipo); Frame graphFrame = SWT_AWT.new_Frame(cmp); graphFrame.add(chartPanel); graphFrame.pack(); GridData gdThis = new GridData(SWT.FILL); gdThis.horizontalAlignment = SWT.FILL; gdThis.verticalAlignment = SWT.FILL; gdThis.grabExcessHorizontalSpace = true; gdThis.grabExcessVerticalSpace = true; this.setLayoutData(gdThis); this.setLayout(new GridLayout(1, false)); }
From source file:org.eclipse.swt.examples.graphics.PathClippingAnimTab.java
/** * Creates the widgets used to control the drawing. *//*from w w w. ja v a 2s. c o m*/ @Override public void createControlPanel(Composite parent) { super.createControlPanel(parent); // color menu ColorMenu cm = new ColorMenu(); cm.setPatternItems(example.checkAdvancedGraphics()); menu = cm.createMenu(parent.getParent(), gb -> { background = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the background to the 5th item in the menu (blue) background = (GraphicsBackground) menu.getItem(4).getData(); // color button Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$ colorButton.setImage(background.getThumbNail()); colorButton.addListener(SWT.Selection, event -> { final Button button = (Button) event.widget; final Composite parent1 = button.getParent(); Rectangle bounds = button.getBounds(); Point point = parent1.toDisplay(new Point(bounds.x, bounds.y)); menu.setLocation(point.x, point.y + bounds.height); menu.setVisible(true); }); }
From source file:org.eclipse.swt.examples.graphics.CountDownTab.java
/** * This method creates the controls specific to the tab. The call to the * createControlPanel method in the super class create the controls that are * defined in the super class.//from w w w.j a va2 s. com * * @param parent * The parent composite */ @Override public void createControlPanel(Composite parent) { super.createControlPanel(parent); if (nextNumber < 1) nextNumber = startNumber; // add selection listener to reset nextNumber after // the sequence has completed playItem.addListener(SWT.Selection, event -> { if (nextNumber < 1) nextNumber = startNumber; }); Composite comp; GridLayout gridLayout = new GridLayout(2, false); // create spinner for line width comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("LineWidth")); //$NON-NLS-1$ lineWidthSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP); lineWidthSpinner.setSelection(20); lineWidthSpinner.setMinimum(1); lineWidthSpinner.setMaximum(100); lineWidthSpinner.addListener(SWT.Selection, event -> { if (!pauseItem.isEnabled()) { example.redraw(); } }); // create drop down combo for antialiasing comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Antialiasing")); //$NON-NLS-1$ aliasCombo = new Combo(comp, SWT.DROP_DOWN); aliasCombo.add("DEFAULT"); aliasCombo.add("OFF"); aliasCombo.add("ON"); aliasCombo.select(0); antialias = aliasValues[0]; aliasCombo.addListener(SWT.Selection, event -> { antialias = aliasValues[aliasCombo.getSelectionIndex()]; if (!pauseItem.isEnabled()) { example.redraw(); } }); // create drop down combo for line cap comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("LineCap")); //$NON-NLS-1$ lineCapCombo = new Combo(comp, SWT.DROP_DOWN); lineCapCombo.add("FLAT"); lineCapCombo.add("SQUARE"); lineCapCombo.add("ROUND"); lineCapCombo.select(0); lineCap = capValues[0]; lineCapCombo.addListener(SWT.Selection, event -> { lineCap = capValues[lineCapCombo.getSelectionIndex()]; if (!pauseItem.isEnabled()) { example.redraw(); } }); }
From source file:org.eclipse.swt.snippets.Snippet319.java
public void go() { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 319"); shell.setBounds(10, 10, 600, 200);/* w w w.ja v a 2 s.co m*/ /* Create SWT controls and add drag source */ final Label swtLabel = new Label(shell, SWT.BORDER); swtLabel.setBounds(10, 10, 580, 50); swtLabel.setText("SWT drag source"); DragSource dragSource = new DragSource(swtLabel, DND.DROP_COPY); dragSource.setTransfer(new MyTypeTransfer()); dragSource.addDragListener(new DragSourceAdapter() { @Override public void dragSetData(DragSourceEvent event) { MyType object = new MyType(); object.name = "content dragged from SWT"; object.time = System.currentTimeMillis(); event.data = object; } }); /* Create AWT/Swing controls */ Composite embeddedComposite = new Composite(shell, SWT.EMBEDDED); embeddedComposite.setBounds(10, 100, 580, 50); embeddedComposite.setLayout(new FillLayout()); Frame frame = SWT_AWT.new_Frame(embeddedComposite); final JLabel jLabel = new JLabel("AWT/Swing drop target"); frame.add(jLabel); /* Register the custom data flavour */ final DataFlavor flavor = new DataFlavor(MIME_TYPE, "MyType custom flavor"); /* * Note that according to jre/lib/flavormap.properties, the preferred way to * augment the default system flavor map is to specify the AWT.DnD.flavorMapFileURL * property in an awt.properties file. * * This snippet uses the alternate approach below in order to provide a simple * stand-alone snippet that demonstrates the functionality. This implementation * works well, but if the instanceof check below fails for some reason when used * in a different context then the drop will not be accepted. */ FlavorMap map = SystemFlavorMap.getDefaultFlavorMap(); if (map instanceof SystemFlavorMap) { SystemFlavorMap systemMap = (SystemFlavorMap) map; systemMap.addFlavorForUnencodedNative(MIME_TYPE, flavor); } /* add drop target */ DropTargetListener dropTargetListener = new DropTargetAdapter() { @Override public void drop(DropTargetDropEvent dropTargetDropEvent) { try { dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY); ByteArrayInputStream inStream = (ByteArrayInputStream) dropTargetDropEvent.getTransferable() .getTransferData(flavor); int available = inStream.available(); byte[] bytes = new byte[available]; inStream.read(bytes); MyType object = restoreFromByteArray(bytes); String string = object.name + ": " + new Date(object.time).toString(); jLabel.setText(string); } catch (Exception e) { e.printStackTrace(); } } }; new DropTarget(jLabel, dropTargetListener); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.examples.addressbook.DataEntryDialog.java
private void createTextWidgets() { if (labels == null) return;// w w w .j a va 2 s. c o m Composite composite = new Composite(shell, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); if (values == null) values = new String[labels.length]; for (int i = 0; i < labels.length; i++) { Label label = new Label(composite, SWT.RIGHT); label.setText(labels[i]); Text text = new Text(composite, SWT.BORDER); GridData gridData = new GridData(); gridData.widthHint = 400; text.setLayoutData(gridData); if (values[i] != null) { text.setText(values[i]); } text.setData("index", Integer.valueOf(i)); addTextListener(text); } }
From source file:grafici.FatturePieChart.java
/** * Default constructor./*from w ww. j av a 2 s . c o m*/ * * @param title * the frame title. */ public FatturePieChart(String title, Composite parent, int style, int tipo) { super(parent, style); titolo = title; Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED); GridData gdCmp = new GridData(SWT.FILL); gdCmp.horizontalAlignment = SWT.FILL; gdCmp.verticalAlignment = SWT.FILL; gdCmp.grabExcessHorizontalSpace = true; gdCmp.grabExcessVerticalSpace = true; cmp.setLayoutData(gdCmp); cmp.setLayout(new GridLayout(1, false)); JPanel chartPanel = createDemoPanel(tipo); Frame graphFrame = SWT_AWT.new_Frame(cmp); graphFrame.add(chartPanel); graphFrame.pack(); GridData gdThis = new GridData(SWT.FILL); gdThis.horizontalAlignment = SWT.FILL; gdThis.verticalAlignment = SWT.FILL; gdThis.grabExcessHorizontalSpace = true; gdThis.grabExcessVerticalSpace = true; this.setLayoutData(gdThis); this.setLayout(new GridLayout(1, false)); }
From source file:ShowPrefs.java
/** * Creates the controls for this page// www . j a v a2s. c o m */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); // Get the preference store IPreferenceStore preferenceStore = getPreferenceStore(); // Create three text fields. // Set the text in each from the preference store new Label(composite, SWT.LEFT).setText("Field One:"); fieldOne = new Text(composite, SWT.BORDER); fieldOne.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fieldOne.setText(preferenceStore.getString(ONE)); new Label(composite, SWT.LEFT).setText("Field Two:"); fieldTwo = new Text(composite, SWT.BORDER); fieldTwo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fieldTwo.setText(preferenceStore.getString(TWO)); new Label(composite, SWT.LEFT).setText("Field Three:"); fieldThree = new Text(composite, SWT.BORDER); fieldThree.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fieldThree.setText(preferenceStore.getString(THREE)); return composite; }
From source file:PlayerTable.java
/** * Creates the main window's contents//from w ww . j a va 2s . c om * * @param parent * the main window * @return Control */ protected Control createContents(Composite parent) { // Create the composite to hold the controls Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); // Create the combo to hold the team names Combo combo = new Combo(composite, SWT.READ_ONLY); combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Create the table viewer to display the players tv = new TableViewer(composite); // Set the content and label providers tv.setContentProvider(new PlayerContentProvider()); tv.setLabelProvider(new PlayerLabelProvider()); tv.setSorter(new PlayerViewerSorter()); // Set up the table Table table = tv.getTable(); table.setLayoutData(new GridData(GridData.FILL_BOTH)); // Add the first name column TableColumn tc = new TableColumn(table, SWT.LEFT); tc.setText("First Name"); tc.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ((PlayerViewerSorter) tv.getSorter()).doSort(PlayerConst.COLUMN_FIRST_NAME); tv.refresh(); } }); // Add the last name column tc = new TableColumn(table, SWT.LEFT); tc.setText("Last Name"); tc.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ((PlayerViewerSorter) tv.getSorter()).doSort(PlayerConst.COLUMN_LAST_NAME); tv.refresh(); } }); // Add the points column tc = new TableColumn(table, SWT.RIGHT); tc.setText("Points"); tc.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ((PlayerViewerSorter) tv.getSorter()).doSort(PlayerConst.COLUMN_POINTS); tv.refresh(); } }); // Add the rebounds column tc = new TableColumn(table, SWT.RIGHT); tc.setText("Rebounds"); tc.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ((PlayerViewerSorter) tv.getSorter()).doSort(PlayerConst.COLUMN_REBOUNDS); tv.refresh(); } }); // Add the assists column tc = new TableColumn(table, SWT.RIGHT); tc.setText("Assists"); tc.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ((PlayerViewerSorter) tv.getSorter()).doSort(PlayerConst.COLUMN_ASSISTS); tv.refresh(); } }); // Add the team names to the combo for (int i = 0, n = model.teams.length; i < n; i++) { combo.add(model.teams[i].getName()); } // Add a listener to change the tableviewer's input combo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { update(model.teams[((Combo) event.widget).getSelectionIndex()]); } }); // Select the first item combo.select(0); update(model.teams[0]); // Pack the columns for (int i = 0, n = table.getColumnCount(); i < n; i++) { table.getColumn(i).pack(); } // Turn on the header and the lines table.setHeaderVisible(true); table.setLinesVisible(true); return composite; }
From source file:eu.stratosphere.addons.visualization.swt.SWTGateToolTip.java
public SWTGateToolTip(Shell parent, ManagementGate managementGate, int x, int y) { super(parent, x, y); int height;//from w ww. j a va2 s . c om this.managementGate = managementGate; if (managementGate.isInputGate()) { setTitle("Input Gate " + managementGate.getIndex()); } else { setTitle("Output Gate " + managementGate.getIndex()); } final Color backgroundColor = getShell().getBackground(); final Color foregroundColor = getShell().getForeground(); final GateVisualizationData gateVisualizationData = (GateVisualizationData) managementGate.getAttachment(); if (gateVisualizationData.isProfilingEnabled()) { this.chart = createChart(gateVisualizationData, backgroundColor); this.chart.setLayoutData(new GridData(GridData.FILL_BOTH)); height = 200; } else { this.chart = null; height = 100; } final Composite tableComposite = new Composite(getShell(), SWT.NONE); tableComposite.setBackground(backgroundColor); tableComposite.setForeground(foregroundColor); final GridLayout tableGridLayout = new GridLayout(2, false); tableGridLayout.marginHeight = 0; tableGridLayout.marginLeft = 0; tableComposite.setLayout(tableGridLayout); // Channel type ChannelType channelType; if (managementGate.isInputGate()) { channelType = managementGate.getVertex().getGroupVertex().getBackwardEdge(managementGate.getIndex()) .getChannelType(); } else { channelType = managementGate.getVertex().getGroupVertex().getForwardEdge(managementGate.getIndex()) .getChannelType(); } final Label channelTypeTextLabel = new Label(tableComposite, SWT.NONE); channelTypeTextLabel.setBackground(backgroundColor); channelTypeTextLabel.setForeground(foregroundColor); channelTypeTextLabel.setText("Channel type:"); this.channelTypeLabel = new Label(tableComposite, SWT.NONE); this.channelTypeLabel.setBackground(backgroundColor); this.channelTypeLabel.setForeground(foregroundColor); this.channelTypeLabel.setText(channelType.toString()); if (!this.managementGate.isInputGate()) { final ManagementGroupEdge groupEdge = this.managementGate.getVertex().getGroupVertex() .getForwardEdge(this.managementGate.getIndex()); final GroupEdgeVisualizationData groupEdgeVisualizationData = (GroupEdgeVisualizationData) groupEdge .getAttachment(); if (groupEdgeVisualizationData.isIOBottleneck()) { this.warningComposite = createWarningComposite(WARNINGTEXT, SWT.ICON_WARNING); height += ICONSIZE; } else { this.warningComposite = null; } } else { this.warningComposite = null; } getShell().setSize(WIDTH, height); finishInstantiation(x, y, WIDTH, false); }