List of usage examples for org.eclipse.swt.widgets Button setText
public void setText(String text)
From source file:ShowMyTitleAreaDialog.java
/** * Creates the main window's contents//ww w .j a va 2s .c o m * * @param parent the main window * @return Control */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, true)); // Create the button Button show = new Button(composite, SWT.NONE); show.setText("Show"); final Shell shell = parent.getShell(); // Display the TitleAreaDialog show.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create and show the dialog MyTitleAreaDialog dlg = new MyTitleAreaDialog(shell); dlg.open(); } }); parent.pack(); return composite; }
From source file:TabbedShellExample.java
TabbedShellExample() { d = new Display(); s = new Shell(d); s.setSize(250, 200);//from ww w.j a va 2s . c om s.setText("A Tabbed Shell Example"); s.setLayout(new FillLayout()); TabFolder tf = new TabFolder(s, SWT.BORDER); TabItem ti1 = new TabItem(tf, SWT.BORDER); ti1.setText("Option Group"); ti1.setControl(new GroupExample(tf, SWT.SHADOW_ETCHED_IN)); TabItem ti2 = new TabItem(tf, SWT.BORDER); ti2.setText("Grid"); ti2.setControl(new GridComposite(tf)); TabItem ti3 = new TabItem(tf, SWT.BORDER); ti3.setText("Text"); Composite c1 = new Composite(tf, SWT.BORDER); c1.setLayout(new FillLayout()); Text t = new Text(c1, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); ti3.setControl(c1); TabItem ti4 = new TabItem(tf, SWT.BORDER); ti4.setText("Settings"); Composite c2 = new Composite(tf, SWT.BORDER); c2.setLayout(new RowLayout()); Text t2 = new Text(c2, SWT.BORDER | SWT.SINGLE | SWT.WRAP | SWT.V_SCROLL); Button b = new Button(c2, SWT.PUSH | SWT.BORDER); b.setText("Save"); ti4.setControl(c2); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
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. j a v a 2 s. c o m } 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:SashFormAdvanced.java
/** * Creates the main window's contents/* w w w . j a v a2 s. c o m*/ * * @param parent the parent window */ private void createContents(Composite parent) { // Our layout will have a row of buttons, and // then a SashForm below it. parent.setLayout(new GridLayout(1, false)); // Create the row of buttons Composite buttonBar = new Composite(parent, SWT.NONE); buttonBar.setLayout(new RowLayout()); Button flip = new Button(buttonBar, SWT.PUSH); flip.setText("Switch Orientation"); Button weights = new Button(buttonBar, SWT.PUSH); weights.setText("Restore Weights"); // Create the SashForm Composite sash = new Composite(parent, SWT.NONE); sash.setLayout(new FillLayout()); sash.setLayoutData(new GridData(GridData.FILL_BOTH)); final SashForm sashForm = new SashForm(sash, SWT.HORIZONTAL); // Change the width of the sashes sashForm.SASH_WIDTH = 20; // Change the color used to paint the sashes sashForm.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GREEN)); // Create the buttons and their event handlers final Button one = new Button(sashForm, SWT.PUSH); one.setText("One"); one.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { maximizeHelper(one, sashForm); } }); final Button two = new Button(sashForm, SWT.PUSH); two.setText("Two"); two.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { maximizeHelper(two, sashForm); } }); final Button three = new Button(sashForm, SWT.PUSH); three.setText("Three"); three.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { maximizeHelper(three, sashForm); } }); // Set the relative weights for the buttons sashForm.setWeights(new int[] { 1, 2, 3 }); // Add the Switch Orientation functionality flip.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { switch (sashForm.getOrientation()) { case SWT.HORIZONTAL: sashForm.setOrientation(SWT.VERTICAL); break; case SWT.VERTICAL: sashForm.setOrientation(SWT.HORIZONTAL); break; } } }); // Add the Restore Weights functionality weights.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { sashForm.setWeights(new int[] { 1, 2, 3 }); } }); }
From source file:org.jfree.experimental.chart.swt.editor.SWTOtherEditor.java
/** * Creates a new instance.// w w w. ja v a2 s . c o m * * @param parent the parent. * @param style the style. * @param chart the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString("Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); //row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString("Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); }
From source file:SendMessage.java
/** * Creates the main window's contents/* w ww . ja v a 2s .c o m*/ * * @param parent the main window * @return Control */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(5, true)); // Create a big text box for the message text final Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); GridData data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 5; text.setLayoutData(data); // Create the Confirm button Button confirm = new Button(composite, SWT.PUSH); confirm.setText("Confirm"); confirm.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Create the Error button Button error = new Button(composite, SWT.PUSH); error.setText("Error"); error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Create the Information button Button information = new Button(composite, SWT.PUSH); information.setText("Information"); information.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Create the Question button Button question = new Button(composite, SWT.PUSH); question.setText("Question"); question.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Create the Warning button Button warning = new Button(composite, SWT.PUSH); warning.setText("Warning"); warning.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Create the label to display the return value final Label label = new Label(composite, SWT.NONE); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 5; label.setLayoutData(data); // Save ourselves some typing final Shell shell = parent.getShell(); // Display a Confirmation dialog confirm.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { boolean b = MessageDialog.openConfirm(shell, "Confirm", text.getText()); label.setText("Returned " + Boolean.toString(b)); } }); // Display an Error dialog error.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { MessageDialog.openError(shell, "Error", text.getText()); label.setText("Returned void"); } }); // Display an Information dialog information.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { MessageDialog.openInformation(shell, "Information", text.getText()); label.setText("Returned void"); } }); // Display a Question dialog question.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { boolean b = MessageDialog.openQuestion(shell, "Question", text.getText()); label.setText("Returned " + Boolean.toString(b)); } }); // Display a Warning dialog warning.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { MessageDialog.openWarning(shell, "Warning", text.getText()); label.setText("Returned void"); } }); return composite; }
From source file:com.rcp.wbw.demo.editor.SWTOtherEditor.java
/** * Creates a new instance.//www.j a v a 2s . com * * @param parent * the parent. * @param style * the style. * @param chart * the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString("Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); // row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString("Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); }
From source file:org.eclipse.swt.examples.addressbook.DataEntryDialog.java
private void createControlButtons() { Composite composite = new Composite(shell, SWT.NONE); composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*from www . ja v a 2 s . c o m*/ composite.setLayout(layout); Button okButton = new Button(composite, SWT.PUSH); okButton.setText(resAddressBook.getString("OK")); okButton.addSelectionListener(widgetSelectedAdapter(e -> shell.close())); Button cancelButton = new Button(composite, SWT.PUSH); cancelButton.setText(resAddressBook.getString("Cancel")); cancelButton.addSelectionListener(widgetSelectedAdapter(e -> { values = null; shell.close(); })); shell.setDefaultButton(okButton); }
From source file:BorderLayout.java
public BorderLayoutSample() { shell.setLayout(new BorderLayout()); Button buttonWest = new Button(shell, SWT.PUSH); buttonWest.setText("West"); buttonWest.setLayoutData(new BorderLayout.BorderData(BorderLayout.WEST)); Button buttonEast = new Button(shell, SWT.PUSH); buttonEast.setText("East"); buttonEast.setLayoutData(new BorderLayout.BorderData(BorderLayout.EAST)); Button buttonNorth = new Button(shell, SWT.PUSH); buttonNorth.setText("North"); buttonNorth.setLayoutData(new BorderLayout.BorderData(BorderLayout.NORTH)); Button buttonSouth = new Button(shell, SWT.PUSH); buttonSouth.setText("South"); buttonSouth.setLayoutData(new BorderLayout.BorderData(BorderLayout.SOUTH)); Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); text.setText("Center"); text.setLayoutData(new BorderLayout.BorderData(BorderLayout.CENTER)); shell.pack();/*from w ww .j a va2s. c o m*/ shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:BugReport.java
public BugReport() { shell.setLayout(new GridLayout(1, true)); shell.setImage(new Image(display, "java2s.gif")); shell.setText("Bug report page"); Group groupBug = new Group(shell, SWT.NULL); groupBug.setText("Bug details"); groupBug.setLayout(new GridLayout(2, false)); groupBug.setLayoutData(new GridData(GridData.FILL_BOTH)); new Label(groupBug, SWT.NULL).setText("Priority"); Combo combo = new Combo(groupBug, SWT.BORDER); combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(groupBug, SWT.NULL).setText("Details"); Text text = new Text(groupBug, SWT.BORDER | SWT.MULTI); text.setLayoutData(new GridData(GridData.FILL_BOTH)); Group groupProxy = new Group(shell, SWT.NULL); groupProxy.setText("Connection setting"); groupProxy.setLayout(new GridLayout(2, false)); groupProxy.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(groupProxy, SWT.NULL).setText("Proxy host"); Text textHost = new Text(groupProxy, SWT.SINGLE | SWT.BORDER); textHost.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(groupProxy, SWT.NULL).setText("Proxy port"); Text textPort = new Text(groupProxy, SWT.SINGLE | SWT.BORDER); textPort.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Button button = new Button(shell, SWT.PUSH); button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); //button.setAlignment(SWT.CENTER); button.setText("Submit bug report"); shell.pack();/* w w w .j av a2 s . co m*/ shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }