List of usage examples for org.eclipse.swt.widgets Button setText
public void setText(String text)
From source file:Ch6FillLayoutComposite.java
public Ch6FillLayoutComposite(Composite parent) { super(parent, SWT.NONE); FillLayout layout = new FillLayout(SWT.VERTICAL); setLayout(layout);/*from w ww . j a v a2 s . co m*/ for (int i = 0; i < 8; ++i) { Button button = new Button(this, SWT.NONE); button.setText("Sample Text"); } }
From source file:Ch6RowLayoutComposite.java
public Ch6RowLayoutComposite(Composite parent) { super(parent, SWT.NONE); RowLayout layout = new RowLayout(SWT.HORIZONTAL); setLayout(layout);//from w w w . j ava2 s . c om for (int i = 0; i < 16; ++i) { Button button = new Button(this, SWT.NONE); button.setText("Sample Text"); button.setLayoutData(new RowData(200 + 5 * i, 20 + i)); } }
From source file:SWTButtonExample.java
SWTButtonExample() { d = new Display(); s = new Shell(d); s.setSize(150, 150);/*from w ww . j a va 2s .c o m*/ s.setText("A Button Example"); final Button b1 = new Button(s, SWT.PUSH); b1.setBounds(50, 50, 75, 40); b1.setText("Push Me"); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:ColorDialogExample.java
ColorDialogExample() { d = new Display(); s = new Shell(d); s.setSize(400, 400);//from w w w . jav a 2 s. com s.setText("A ColorDialog Example"); s.setLayout(new FillLayout(SWT.VERTICAL)); final Text t = new Text(s, SWT.BORDER | SWT.MULTI); final Button b = new Button(s, SWT.PUSH | SWT.BORDER); b.setText("Change Color"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ColorDialog cd = new ColorDialog(s); cd.setText("ColorDialog Demo"); cd.setRGB(new RGB(255, 255, 255)); RGB newColor = cd.open(); if (newColor == null) { return; } t.setBackground(new Color(d, newColor)); } }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:PopupListTest.java
/** * Creates the main window's contents/* w w w.j ava 2 s . com*/ * * @param shell the main window */ private void createContents(final Shell shell) { shell.setLayout(new RowLayout()); // Create a button to launch the list Button button = new Button(shell, SWT.PUSH); button.setText("Push Me"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create a list PopupList list = new PopupList(shell); // Add the items to the list list.setItems(OPTIONS); // Open the list and get the selected item String selected = list.open(shell.getBounds()); // Print the item to the console System.out.println(selected); } }); }
From source file:FontDialogExample.java
FontDialogExample() { d = new Display(); s = new Shell(d); s.setSize(400, 400);/*from w w w . j a v a 2s. c o m*/ s.setText("A FontDialog Example"); s.setLayout(new FillLayout(SWT.VERTICAL)); final Text t = new Text(s, SWT.BORDER | SWT.MULTI); final Button b = new Button(s, SWT.PUSH | SWT.BORDER); b.setText("Change Font"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FontDialog fd = new FontDialog(s, SWT.NONE); fd.setText("Select Font"); fd.setRGB(new RGB(0, 0, 255)); FontData defaultFont = new FontData("Courier", 10, SWT.BOLD); fd.setFontData(defaultFont); FontData newFont = fd.open(); if (newFont == null) return; t.setFont(new Font(d, newFont)); t.setForeground(new Color(d, fd.getRGB())); } }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:RowLayoutSample.java
public RowLayoutSample() { RowLayout rowLayout = new RowLayout(); //rowLayout.fill = true; //rowLayout.justify = true; //rowLayout.pack = false; //rowLayout.type = SWT.VERTICAL; //rowLayout.wrap = false; shell.setLayout(rowLayout);/*from w w w. java2s .co m*/ Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); button1.setLayoutData(new RowData(100, 35)); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); //shell.setSize(120, 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(); }
From source file:ButtonStyles.java
public ButtonStyles() { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(5, true)); Button arrowButton = new Button(shell, SWT.ARROW); arrowButton.setText("&Arrow Button"); Button checkButton = new Button(shell, SWT.CHECK); checkButton.setText("&Check Button"); Button pushButton = new Button(shell, SWT.PUSH); pushButton.setText("&Push Button"); Button radioButton = new Button(shell, SWT.RADIO); radioButton.setText("&Radio Button"); Button toggleButton = new Button(shell, SWT.TOGGLE); toggleButton.setText("&Toggle Button"); // shell.pack(); shell.setSize(500, 100);/*from w w w. j a v a 2s. 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(); }
From source file:Ch6GridLayoutAllOptionsComposite.java
public Ch6GridLayoutAllOptionsComposite(Composite parent) { super(parent, SWT.NONE); int[] fillStyles = { SWT.NONE, GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, GridData.FILL_BOTH }; int[] alignStyles = { SWT.NONE, GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.HORIZONTAL_ALIGN_END, GridData.HORIZONTAL_ALIGN_CENTER, GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_END, GridData.VERTICAL_ALIGN_CENTER, GridData.VERTICAL_ALIGN_FILL }; GridLayout layout = new GridLayout(fillStyles.length, false); setLayout(layout);// w w w. j a va2s . com int count = 0; for (int i = 0; i < alignStyles.length; ++i) { for (int j = 0; j < fillStyles.length; ++j) { Button button = new Button(this, SWT.NONE); button.setText("Cell " + count++); button.setLayoutData(new GridData(fillStyles[j] | alignStyles[i])); } } }
From source file:FontRegistryExample.java
private void init() { shell.setLayout(new GridLayout(2, false)); fontRegistry = new FontRegistry(display); fontRegistry.put("button-text", new FontData[] { new FontData("Arial", 9, SWT.BOLD) }); fontRegistry.put("code", new FontData[] { new FontData("Courier New", 10, SWT.NORMAL) }); Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.WRAP); text.setFont(fontRegistry.get("code")); text.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); text.setText("public static void main() {\n\tSystem.out.println(\"Hello\"); \n}"); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2;/*from ww w . j a va 2 s.co m*/ text.setLayoutData(gd); Button executeButton = new Button(shell, SWT.PUSH); executeButton.setText("Execute"); executeButton.setFont(fontRegistry.get("button-text")); Button cancelButton = new Button(shell, SWT.PUSH); cancelButton.setText("Cancel"); cancelButton.setFont(fontRegistry.get("button-text")); }