package swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.TableItem;
public class She extends Shell {
private Table table;
private TableItem tm;
private TableItem tm_1;
private TableItem tm_2;
private Button button;
/**
* Launch the application.
* @param args
*/
public static void main(String args[]) {
try {
Display display = Display.getDefault();
She shell = new She(display);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the shell.
* @param display
*/
public She(Display display) {
super(display, SWT.SHELL_TRIM);
table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION);
table.setBounds(10, 39, 414, 213);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn t = new TableColumn(table, SWT.NONE);
t.setWidth(100);
t.setText("姓名");
TableColumn t_1 = new TableColumn(table, SWT.NONE);
t_1.setWidth(100);
t_1.setText("年龄 ");
TableColumn t_2 = new TableColumn(table, SWT.NONE);
t_2.setWidth(100);
t_2.setText("性别 ");
TableColumn t_3 = new TableColumn(table, SWT.NONE);
t_3.setWidth(100);
t_3.setText("身高");
button = new Button(this, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tm = new TableItem(table, SWT.NONE);
tm.setText(new String[]{"张三","22","男","175cm"});
tm_1 = new TableItem(table, SWT.NONE);
tm_1.setText(new String[]{"李四","21","女","172cm"});
tm_2 = new TableItem(table, SWT.NONE);
tm_2.setText(new String[]{"王五","25","男","170cm"});
}
});
button.setBounds(146, 10, 80, 27);
button.setText("/u663E/u793A ");
createContents();
}
/**
* Create contents of the shell.
*/
protected void createContents() {
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}