List of usage examples for org.eclipse.swt.widgets Button Button
public Button(Composite parent, int style)
From source file:org.eclipse.swt.examples.controlexample.ComboTab.java
/** * Creates the "Style" group./*from w w w . ja v a 2 s. co m*/ */ @Override void createStyleGroup() { super.createStyleGroup(); /* Create the extra widgets */ dropDownButton = new Button(styleGroup, SWT.RADIO); dropDownButton.setText("SWT.DROP_DOWN"); simpleButton = new Button(styleGroup, SWT.RADIO); simpleButton.setText("SWT.SIMPLE"); readOnlyButton = new Button(styleGroup, SWT.CHECK); readOnlyButton.setText("SWT.READ_ONLY"); }
From source file:com.rcp.wbw.demo.editor.SWTNumberAxisEditor.java
/** * Creates a new editor./*from w w w .j ava 2s .c om*/ * * @param parent * the parent. * @param style * the style. * @param axis * the axis. */ public SWTNumberAxisEditor(Composite parent, int style, NumberAxis axis) { super(parent, style, axis); this.autoRange = axis.isAutoRange(); this.minimumValue = axis.getLowerBound(); this.maximumValue = axis.getUpperBound(); TabItem item2 = new TabItem(getOtherTabs(), SWT.NONE); item2.setText(" " + localizationResources.getString("Range") + " "); Composite range = new Composite(getOtherTabs(), SWT.NONE); range.setLayout(new GridLayout(2, true)); item2.setControl(range); this.autoRangeCheckBox = new Button(range, SWT.CHECK); this.autoRangeCheckBox.setText(localizationResources.getString("Auto-adjust_range")); this.autoRangeCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); this.autoRangeCheckBox.setSelection(this.autoRange); this.autoRangeCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { toggleAutoRange(); } }); new Label(range, SWT.NONE).setText(localizationResources.getString("Minimum_range_value")); this.minimumRangeValue = new Text(range, SWT.BORDER); this.minimumRangeValue.setText(String.valueOf(this.minimumValue)); this.minimumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.minimumRangeValue.setEnabled(!this.autoRange); // this.minimumRangeValue.addModifyListener(this); // this.minimumRangeValue.addVerifyListener(this); this.minimumRangeValue.addFocusListener(this); new Label(range, SWT.NONE).setText(localizationResources.getString("Maximum_range_value")); this.maximumRangeValue = new Text(range, SWT.BORDER); this.maximumRangeValue.setText(String.valueOf(this.maximumValue)); this.maximumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.maximumRangeValue.setEnabled(!this.autoRange); // this.maximumRangeValue.addModifyListener(this); // this.maximumRangeValue.addVerifyListener(this); this.maximumRangeValue.addFocusListener(this); }
From source file:org.eclipse.swt.examples.graphics.PathClippingTab.java
/** * Creates the widgets used to control the drawing. */// w ww . j av a 2s.co m @Override public void createControlPanel(Composite parent) { // create drop down combo for choosing clipping Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Clipping")); //$NON-NLS-1$ clippingCb = new Combo(comp, SWT.DROP_DOWN); clippingCb.add(GraphicsExample.getResourceString("Circles")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Rectangle")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Oval")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Word")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Star")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Triangles")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Default")); //$NON-NLS-1$ clippingCb.select(0); clippingCb.addListener(SWT.Selection, event -> example.redraw()); // 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 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.RegionClippingTab.java
/** * Creates the widgets used to control the drawing. *//*from w w w. j a v a2 s. c om*/ @Override public void createControlPanel(Composite parent) { // create drop down combo for choosing clipping Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Clipping")); //$NON-NLS-1$ clippingCb = new Combo(comp, SWT.DROP_DOWN); clippingCb.add(GraphicsExample.getResourceString("Region1")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Region2")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Add")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Sub")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Inter")); //$NON-NLS-1$ clippingCb.select(0); clippingCb.addListener(SWT.Selection, event -> example.redraw()); // color menu ColorMenu cm = new ColorMenu(); menu1 = cm.createMenu(parent.getParent(), gb -> { colorGB1 = gb; colorButton1.setImage(gb.getThumbNail()); example.redraw(); }); menu2 = cm.createMenu(parent.getParent(), gb -> { colorGB2 = gb; colorButton2.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the color to blue colorGB1 = (GraphicsBackground) menu1.getItem(4).getData(); // initialize the color to red colorGB2 = (GraphicsBackground) menu2.getItem(2).getData(); // color button 1 comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); colorButton1 = new Button(comp, SWT.PUSH); colorButton1.setText(GraphicsExample.getResourceString("Color1")); //$NON-NLS-1$ colorButton1.setImage(colorGB1.getThumbNail()); colorButton1.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)); menu1.setLocation(point.x, point.y + bounds.height); menu1.setVisible(true); }); // color button 2 comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); colorButton2 = new Button(comp, SWT.PUSH); colorButton2.setText(GraphicsExample.getResourceString("Color2")); //$NON-NLS-1$ colorButton2.setImage(colorGB2.getThumbNail()); colorButton2.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)); menu2.setLocation(point.x, point.y + bounds.height); menu2.setVisible(true); }); }
From source file:CoolBarTest.java
/** * Creates two stacked buttons/*from w w w . j a v a 2s. co m*/ * * @param composite the parent composite * @return Control */ private Control createStackedButtons(Composite composite) { Composite c = new Composite(composite, SWT.NONE); c.setLayout(new GridLayout(1, false)); new Button(c, SWT.PUSH).setText("Button One"); new Button(c, SWT.PUSH).setText("Button Two"); return c; }
From source file:TabComplex.java
/** * Gets the control for tab one/*from w w w . j a v a 2s . c om*/ * * @param tabFolder the parent tab folder * @return Control */ private Control getTabOneControl(TabFolder tabFolder) { // Create a composite and add four buttons to it Composite composite = new Composite(tabFolder, SWT.NONE); composite.setLayout(new FillLayout(SWT.VERTICAL)); new Button(composite, SWT.PUSH).setText("Button one"); new Button(composite, SWT.PUSH).setText("Button two"); new Button(composite, SWT.PUSH).setText("Button three"); new Button(composite, SWT.PUSH).setText("Button four"); return composite; }
From source file:org.eclipse.swt.examples.paint.TextTool.java
/** * Handles a mouseDown event./*from ww w . j a v a 2 s. com*/ * * @param event the mouse event detail information */ @Override public void mouseDown(MouseEvent event) { if (event.button == 1) { // draw with left mouse button getPaintSurface().commitRubberbandSelection(); } else { // set text with right mouse button getPaintSurface().clearRubberbandSelection(); Shell shell = getPaintSurface().getShell(); final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setText(PaintExample.getResourceString("tool.Text.dialog.title")); dialog.setLayout(new GridLayout()); Label label = new Label(dialog, SWT.NONE); label.setText(PaintExample.getResourceString("tool.Text.dialog.message")); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); final Text field = new Text(dialog, SWT.SINGLE | SWT.BORDER); field.setText(drawText); field.selectAll(); field.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Composite buttons = new Composite(dialog, SWT.NONE); GridLayout layout = new GridLayout(2, true); layout.marginWidth = 0; buttons.setLayout(layout); buttons.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); Button ok = new Button(buttons, SWT.PUSH); ok.setText(PaintExample.getResourceString("OK")); ok.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); ok.addSelectionListener(widgetSelectedAdapter(e -> { drawText = field.getText(); dialog.dispose(); })); Button cancel = new Button(buttons, SWT.PUSH); cancel.setText(PaintExample.getResourceString("Cancel")); cancel.addSelectionListener(widgetSelectedAdapter(e -> dialog.dispose())); dialog.setDefaultButton(ok); dialog.pack(); dialog.open(); Display display = dialog.getDisplay(); while (!shell.isDisposed() && !dialog.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }
From source file:org.eclipse.swt.examples.controlexample.ToolTipTab.java
/** * Creates the "Style" group./* w w w . ja v a 2s .c om*/ */ @Override void createStyleGroup() { super.createStyleGroup(); /* Create the extra widgets */ balloonButton = new Button(styleGroup, SWT.CHECK); balloonButton.setText("SWT.BALLOON"); iconErrorButton = new Button(styleGroup, SWT.RADIO); iconErrorButton.setText("SWT.ICON_ERROR"); iconInformationButton = new Button(styleGroup, SWT.RADIO); iconInformationButton.setText("SWT.ICON_INFORMATION"); iconWarningButton = new Button(styleGroup, SWT.RADIO); iconWarningButton.setText("SWT.ICON_WARNING"); noIconButton = new Button(styleGroup, SWT.RADIO); noIconButton.setText(ControlExample.getResourceString("No_Icon")); }
From source file:org.eclipse.swt.examples.controlexample.ExpandBarTab.java
/** * Creates the "Style" group./*from w w w. ja v a 2 s.c o m*/ */ @Override void createStyleGroup() { super.createStyleGroup(); /* Create the extra widgets */ verticalButton = new Button(styleGroup, SWT.CHECK); verticalButton.setText("SWT.V_SCROLL"); verticalButton.setSelection(true); borderButton = new Button(styleGroup, SWT.CHECK); borderButton.setText("SWT.BORDER"); }
From source file:org.eclipse.swt.examples.controlexample.LabelTab.java
/** * Creates the "Style" group./* w ww.java2 s . c o m*/ */ @Override void createStyleGroup() { super.createStyleGroup(); /* Create the extra widgets */ wrapButton = new Button(styleGroup, SWT.CHECK); wrapButton.setText("SWT.WRAP"); separatorButton = new Button(styleGroup, SWT.CHECK); separatorButton.setText("SWT.SEPARATOR"); horizontalButton = new Button(styleGroup, SWT.RADIO); horizontalButton.setText("SWT.HORIZONTAL"); verticalButton = new Button(styleGroup, SWT.RADIO); verticalButton.setText("SWT.VERTICAL"); Group styleSubGroup = new Group(styleGroup, SWT.NONE); styleSubGroup.setLayout(new GridLayout()); shadowInButton = new Button(styleSubGroup, SWT.RADIO); shadowInButton.setText("SWT.SHADOW_IN"); shadowOutButton = new Button(styleSubGroup, SWT.RADIO); shadowOutButton.setText("SWT.SHADOW_OUT"); shadowNoneButton = new Button(styleSubGroup, SWT.RADIO); shadowNoneButton.setText("SWT.SHADOW_NONE"); borderButton = new Button(styleGroup, SWT.CHECK); borderButton.setText("SWT.BORDER"); }