List of usage examples for org.eclipse.swt.widgets Button setText
public void setText(String text)
From source file:Ch12ClipboardComposite.java
public Ch12ClipboardComposite(Composite parent) { super(parent, SWT.NONE); FillLayout layout = new FillLayout(); setLayout(layout);//from ww w . j a v a 2s. co m Button b = new Button(this, SWT.NONE); b.setText("Copy to system clipboard"); b.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { Clipboard clipboard = new Clipboard(getDisplay()); String rtfData = "{\\rtf1\\b\\i Hello World}"; RTFTransfer rtfTransfer = RTFTransfer.getInstance(); clipboard.setContents(new Object[] { rtfData }, new Transfer[] { rtfTransfer }); clipboard.dispose(); } public void widgetDefaultSelected(SelectionEvent e) { } }); }
From source file:RowLayoutExample.java
RowLayoutExample() { d = new Display(); s = new Shell(d); s.setSize(250, 250);//from w ww . ja va 2s .c o m s.setText("A RowLayout Example"); s.setLayout(new RowLayout()); final Text t = new Text(s, SWT.SINGLE | SWT.BORDER); final Button b = new Button(s, SWT.BORDER); final Button b1 = new Button(s, SWT.BORDER); b.setText("OK"); b1.setText("Cancel"); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:MainClass.java
public void createButton(Composite c, int style, String text) { Button b = new Button(c, style); b.setText(text); }
From source file:ShowError.java
/** * Creates the main window's contents/*from w w w.jav a 2 s.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, false)); // Create a big text box to accept error text final Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); text.setLayoutData(new GridData(GridData.FILL_BOTH)); // Create the button to launch the error dialog Button show = new Button(composite, SWT.PUSH); show.setText("Show Error"); show.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the required Status object Status status = new Status(IStatus.ERROR, "My Plug-in ID", 0, "Status Error Message", null); // Display the dialog ErrorDialog.openError(Display.getCurrent().getActiveShell(), "JFace Error", text.getText(), status); } }); return composite; }
From source file:Ch6GridSpanComposite.java
public Ch6GridSpanComposite(Composite parent) { super(parent, SWT.NONE); GridLayout layout = new GridLayout(3, false); setLayout(layout);//w w w . ja v a 2s. c o m Button b = new Button(this, SWT.NONE); b.setText("Button 1"); b = new Button(this, SWT.NONE); b.setText("Button 2"); b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); b = new Button(this, SWT.NONE); b.setText("Button 3"); Text t = new Text(this, SWT.MULTI); GridData data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; data.verticalSpan = 2; t.setLayoutData(data); b = new Button(this, SWT.NONE); b.setText("Button 4"); b.setLayoutData(new GridData(GridData.FILL_VERTICAL)); b = new Button(this, SWT.NONE); b.setText("Button 5"); b.setLayoutData(new GridData(GridData.FILL_VERTICAL)); }
From source file:GridLayoutSample.java
public GridLayoutSample() { GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;/* w w w. j a va2s . c om*/ gridLayout.makeColumnsEqualWidth = true; shell.setLayout(gridLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); button1.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); list.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); GridData gridData = new GridData(GridData.VERTICAL_ALIGN_END); gridData.horizontalIndent = 5; button2.setLayoutData(gridData); Button button3 = new Button(shell, SWT.PUSH); button3.setText("3"); button3.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL)); shell.pack(); 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:FormLayoutSample.java
public FormLayoutSample() { shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); FormData formData = new FormData(); formData.left = new FormAttachment(20); formData.top = new FormAttachment(20); button1.setLayoutData(formData);/*from w ww.j av a2 s . c o m*/ Button button2 = new Button(shell, SWT.PUSH); button2.setText("button number 2"); formData = new FormData(); formData.left = new FormAttachment(button1, 0, SWT.CENTER); formData.top = new FormAttachment(button1, 0, SWT.CENTER); button2.setLayoutData(formData); // Button button3 = new Button(shell, SWT.PUSH); // button3.setText("3"); // // formData = new FormData(); // formData.top = new FormAttachment(button2, 10); // formData.left = new FormAttachment(button2, 0, SWT.LEFT); // button3.setLayoutData(formData); shell.pack(); //shell.setSize(500, 600); shell.open(); //textUser.forceFocus(); //System.out.println("Button3: " + button3.getBounds()); // 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:BusyIndicatorTest.java
/** * Create the window's contents/*from w w w.j a v a 2 s. c o m*/ * * @param shell the parent shell */ private void createContents(Shell shell) { shell.setLayout(new FillLayout()); final Button button = new Button(shell, SWT.PUSH); button.setText(RUN); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Change the button's text button.setText(IS_RUNNING); // Show the busy indicator BusyIndicator.showWhile(button.getDisplay(), new SleepThread(SLEEP_TIME)); // Thread has completed; reset the button's text button.setText(RUN); } }); }
From source file:GridLayoutSampleSpan.java
public GridLayoutSampleSpan() { GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;/*w w w.jav a 2s. c o m*/ gridLayout.makeColumnsEqualWidth = true; shell.setLayout(gridLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); button1.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); list.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); GridData gridData = new GridData(GridData.VERTICAL_ALIGN_END); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; button2.setLayoutData(gridData); Button button3 = new Button(shell, SWT.PUSH); button3.setText("3"); GridData gridData2 = new GridData(GridData.VERTICAL_ALIGN_END); gridData2.verticalSpan = 3; button3.setLayoutData(gridData2); shell.pack(); 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:SWTDefaultButton.java
public SWTDefaultButton() { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); final String[] ratings = new String[] { "Killer!", "Good stuff", "So-so", "Needs work" }; final Button[] radios = new Button[ratings.length]; for (int i = 0; i < ratings.length; i++) { radios[i] = new Button(shell, SWT.RADIO); radios[i].setText(ratings[i]);// w ww .j av a 2 s. c o m } Button cancelButton = new Button(shell, SWT.PUSH); cancelButton.setText("Canel"); Button rateButton = new Button(shell, SWT.PUSH); rateButton.setText("Rate!"); rateButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { for (int i = 0; i < radios.length; i++) if (radios[i].getSelection()) System.out.println("Rating: " + ratings[i]); } public void widgetDefaultSelected(SelectionEvent e) { System.out.println("Default selection"); } }); shell.setDefaultButton(rateButton); System.out.println(shell.getDefaultButton()); shell.pack(); 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(); }