List of usage examples for org.eclipse.swt.widgets Button Button
public Button(Composite parent, int style)
From source file:org.eclipse.swt.examples.graphics.PathTab.java
@Override public void createControlPanel(Composite parent) { Composite comp;/* ww w. j a v a 2 s. c o m*/ // create draw button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); drawButton = new Button(comp, SWT.TOGGLE); drawButton.setText(GraphicsExample.getResourceString("DrawPath")); //$NON-NLS-1$ drawButton.addListener(SWT.Selection, event -> example.redraw()); drawButton.setSelection(true); // create fill button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); fillButton = new Button(comp, SWT.TOGGLE); fillButton.setText(GraphicsExample.getResourceString("FillPath")); //$NON-NLS-1$ fillButton.addListener(SWT.Selection, event -> example.redraw()); // create close button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); closeButton = new Button(comp, SWT.TOGGLE); closeButton.setText(GraphicsExample.getResourceString("ClosePath")); //$NON-NLS-1$ closeButton.addListener(SWT.Selection, event -> example.redraw()); // create color button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); ColorMenu cm = new ColorMenu(); cm.setPatternItems(example.checkAdvancedGraphics()); menu = cm.createMenu(parent.getParent(), gb -> { fillColor = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the foreground to the 5th item in the menu (green) fillColor = (GraphicsBackground) menu.getItem(3).getData(); // color button colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("FillColor")); //$NON-NLS-1$ colorButton.setImage(fillColor.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:AdvancedBrowser.java
public AdvancedBrowser(String location) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Advanced Browser"); shell.setLayout(new FormLayout()); Composite controls = new Composite(shell, SWT.NONE); FormData data = new FormData(); data.top = new FormAttachment(0, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); controls.setLayoutData(data);//from w w w . j av a 2 s . c o m Label status = new Label(shell, SWT.NONE); data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.bottom = new FormAttachment(100, 0); status.setLayoutData(data); final Browser browser = new Browser(shell, SWT.BORDER); data = new FormData(); data.top = new FormAttachment(controls); data.bottom = new FormAttachment(status); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); browser.setLayoutData(data); controls.setLayout(new GridLayout(7, false)); Button button = new Button(controls, SWT.PUSH); button.setText("Back"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.back(); } }); button = new Button(controls, SWT.PUSH); button.setText("Forward"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.forward(); } }); button = new Button(controls, SWT.PUSH); button.setText("Refresh"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.refresh(); } }); button = new Button(controls, SWT.PUSH); button.setText("Stop"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.stop(); } }); final Text url = new Text(controls, SWT.BORDER); url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); url.setFocus(); button = new Button(controls, SWT.PUSH); button.setText("Go"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.setUrl(url.getText()); } }); Label throbber = new Label(controls, SWT.NONE); throbber.setText(AT_REST); shell.setDefaultButton(button); browser.addCloseWindowListener(new AdvancedCloseWindowListener()); browser.addLocationListener(new AdvancedLocationListener(url)); browser.addProgressListener(new AdvancedProgressListener(throbber)); browser.addStatusTextListener(new AdvancedStatusTextListener(status)); // Go to the initial URL if (location != null) { browser.setUrl(location); } shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.examples.controlexample.ToolTipTab.java
/** * Creates the "Example" group.//from w w w .j a va2 s .c o m */ @Override void createExampleGroup() { super.createExampleGroup(); /* Create a group for the tooltip visibility check box */ toolTipGroup = new Group(exampleGroup, SWT.NONE); toolTipGroup.setLayout(new GridLayout()); toolTipGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); toolTipGroup.setText("ToolTip"); visibleButton = new Button(toolTipGroup, SWT.CHECK); visibleButton.setText(ControlExample.getResourceString("Visible")); visibleButton.addSelectionListener(widgetSelectedAdapter(event -> setExampleWidgetVisibility())); }
From source file:org.talend.dataprofiler.chart.util.HideSeriesChartDialog.java
private Composite createUtilityControl(Composite parent) { Composite comp = new Composite(parent, SWT.BORDER); comp.setLayout(new RowLayout()); comp.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY)); if (isCountAvgNull) { XYDataset dataset = chart.getXYPlot().getDataset(); int count = dataset.getSeriesCount(); for (int i = 0; i < count; i++) { Button checkBtn = new Button(comp, SWT.CHECK); checkBtn.setText(dataset.getSeriesKey(i).toString()); checkBtn.setSelection(true); checkBtn.addSelectionListener(listener); checkBtn.setData(SERIES_KEY_ID, i); }//from w w w . ja va 2s . c om } if (isMinMaxDate) { CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryDataset dataset = plot.getDataset(); int count = dataset.getRowCount(); for (int i = 0; i < count; i++) { Button checkBtn = new Button(comp, SWT.CHECK); checkBtn.setText(dataset.getRowKey(i).toString()); checkBtn.setSelection(true); checkBtn.addSelectionListener(listener); checkBtn.setData(SERIES_KEY_ID, i); } } return comp; }
From source file:TabbedShellExample.java
public GroupExample(Composite c, int style) { super(c, SWT.NO_BACKGROUND); this.setSize(110, 75); this.setLayout(new FillLayout()); final Group g = new Group(this, style); g.setSize(110, 75);//from w w w . ja v a2 s . c o m g.setText("Options Group"); b1 = new Button(g, SWT.RADIO); b1.setBounds(10, 20, 75, 15); b1.setText("Option One"); b2 = new Button(g, SWT.RADIO); b2.setBounds(10, 35, 75, 15); b2.setText("Option Two"); b3 = new Button(g, SWT.RADIO); b3.setBounds(10, 50, 80, 15); b3.setText("Option Three"); }
From source file:MainClass.java
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, true)); new Label(composite, SWT.LEFT).setText("Do you have complaints?"); Composite yesNo = new Composite(composite, SWT.NONE); yesNo.setLayout(new FillLayout(SWT.VERTICAL)); yes = new Button(yesNo, SWT.RADIO); yes.setText("Yes"); no = new Button(yesNo, SWT.RADIO); no.setText("No"); setControl(composite);/* w ww . j a va2 s. com*/ }
From source file:org.eclipse.swt.snippets.Snippet366.java
private static void makeArrowGroup() { Group arrowGroup = new Group(shell, SWT.None); arrowGroup.setText("Arrow group"); arrowGroup.setLayout(new RowLayout()); new Button(arrowGroup, SWT.ARROW | SWT.LEFT); new Button(arrowGroup, SWT.ARROW | SWT.RIGHT); new Button(arrowGroup, SWT.ARROW | SWT.UP); new Button(arrowGroup, SWT.ARROW | SWT.DOWN); }
From source file:Survey.java
/** * Creates the page controls/*from ww w .j ava2 s . co m*/ */ public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, true)); new Label(composite, SWT.LEFT).setText("Do you have complaints?"); Composite yesNo = new Composite(composite, SWT.NONE); yesNo.setLayout(new FillLayout(SWT.VERTICAL)); yes = new Button(yesNo, SWT.RADIO); yes.setText("Yes"); no = new Button(yesNo, SWT.RADIO); no.setText("No"); setControl(composite); }
From source file:org.eclipse.swt.examples.controlexample.ExpandBarTab.java
/** * Creates the "Example" widgets./*from w ww. jav a 2 s .c om*/ */ @Override void createExampleWidgets() { /* Compute the widget style */ int style = getDefaultStyle(); if (borderButton.getSelection()) style |= SWT.BORDER; if (verticalButton.getSelection()) style |= SWT.V_SCROLL; /* Create the example widgets */ expandBar1 = new ExpandBar(expandBarGroup, style); // First item Composite composite = new Composite(expandBar1, SWT.NONE); composite.setLayout(new GridLayout()); new Button(composite, SWT.PUSH).setText("SWT.PUSH"); new Button(composite, SWT.RADIO).setText("SWT.RADIO"); new Button(composite, SWT.CHECK).setText("SWT.CHECK"); new Button(composite, SWT.TOGGLE).setText("SWT.TOGGLE"); ExpandItem item = new ExpandItem(expandBar1, SWT.NONE, 0); item.setText(ControlExample.getResourceString("Item1_Text")); item.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); item.setControl(composite); item.setImage(instance.images[ControlExample.ciClosedFolder]); // Second item composite = new Composite(expandBar1, SWT.NONE); composite.setLayout(new GridLayout(2, false)); new Label(composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_ERROR)); new Label(composite, SWT.NONE).setText("SWT.ICON_ERROR"); new Label(composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_INFORMATION)); new Label(composite, SWT.NONE).setText("SWT.ICON_INFORMATION"); new Label(composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_WARNING)); new Label(composite, SWT.NONE).setText("SWT.ICON_WARNING"); new Label(composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_QUESTION)); new Label(composite, SWT.NONE).setText("SWT.ICON_QUESTION"); item = new ExpandItem(expandBar1, SWT.NONE, 1); item.setText(ControlExample.getResourceString("Item2_Text")); item.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); item.setControl(composite); item.setImage(instance.images[ControlExample.ciOpenFolder]); item.setExpanded(true); }
From source file:CoolBarExamples.java
public CoolBarExamples() { shell.setLayout(new GridLayout()); final CoolBar coolBar = new CoolBar(shell, SWT.NONE); coolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // cool item with a text field. CoolItem textItem = new CoolItem(coolBar, SWT.NONE); Text text = new Text(coolBar, SWT.BORDER | SWT.DROP_DOWN); text.setText("TEXT"); text.pack();//w ww . j ava 2 s . c om Point size = text.getSize(); textItem.setControl(text); textItem.setSize(textItem.computeSize(size.x, size.y)); // cool item with a label. CoolItem labelItem = new CoolItem(coolBar, SWT.NONE); Label label = new Label(coolBar, SWT.NONE); label.setText("LABEL"); label.pack(); size = label.getSize(); labelItem.setControl(label); labelItem.setSize(textItem.computeSize(size.x, size.y)); // cool item with a button. CoolItem buttonItem = new CoolItem(coolBar, SWT.NONE | SWT.DROP_DOWN); Composite composite = new Composite(coolBar, SWT.NONE); composite.setLayout(new GridLayout(2, true)); Button button1 = new Button(composite, SWT.PUSH); button1.setText("Button 1"); button1.pack(); Button button2 = new Button(composite, SWT.PUSH); button2.setText("Button 2"); button2.pack(); composite.pack(); size = composite.getSize(); buttonItem.setControl(composite); buttonItem.setSize(buttonItem.computeSize(size.x, size.y)); // // Test cool item adding method. // Label label2 = new Label(coolBar, SWT.NONE); // label2.setText("label2"); // addControlToCoolBar(label2, SWT.DROP_DOWN, coolBar); try { setState(coolBar, new File("coolbar.state")); } catch (IOException e1) { e1.printStackTrace(); } shell.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { try { saveState(coolBar, new File("coolbar.state")); } catch (IOException e) { e.printStackTrace(); } } }); shell.setSize(300, 120); // shell.pack(); shell.open(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }