List of usage examples for org.eclipse.swt.widgets Button setText
public void setText(String text)
From source file:PrintKTableExample.java
public PrintSWTTableExample() { // create some gui with a SWT table display = new Display(); final Shell shell = new Shell(display); final org.eclipse.swt.layout.GridLayout gridLayout = new org.eclipse.swt.layout.GridLayout(); gridLayout.numColumns = 2;/*from w ww. ja v a2 s. com*/ shell.setLayout(gridLayout); final Color red = display.getSystemColor(SWT.COLOR_RED); final Table table_swt = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION); final GridData gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; table_swt.setLayoutData(gridData); table_swt.setLinesVisible(true); TableColumn column1 = new TableColumn(table_swt, SWT.NONE); TableColumn column2 = new TableColumn(table_swt, SWT.NONE); TableColumn column3 = new TableColumn(table_swt, SWT.NONE); column1.setText("Column1"); column2.setText("Column2"); column3.setText("Column3"); for (int i = 0; i < 100; i++) { TableItem item = new TableItem(table_swt, SWT.NONE); item.setText(new String[] { "cell " + i + " 0", "cell " + i + " 1", "cell " + i + "2" }); } column1.pack(); column2.pack(); column3.pack(); final Button butPrint = new Button(shell, SWT.NONE); butPrint.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // create a document with default settings from PageSetup final PDocument doc = new PDocument("SWT Table Printing Example"); // put some header text on it PTextBox t; t = new PTextBox(doc); t.setText("SWT Table Printing Example"); new PVSpace(doc, 0.1); new PHLine(doc, 0.02, SWT.COLOR_BLACK); new PVSpace(doc, 0.5); // create the table SWTPTable table = new SWTPTable(doc); table.setTable(table_swt); table.setBoxProvider(new PTableBoxProvider()); PrintPreview pr = new PrintPreview(null, "Test", IconSource.getImage("print"), doc); pr.open(); } }); butPrint.setText("Print Preview"); final Button butClose = new Button(shell, SWT.NONE); butClose.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.dispose(); } }); butClose.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); butClose.setText("Close"); // Show the shell shell.setSize(300, 400); shell.setText("SWT Table Printing Example"); shell.setVisible(true); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }