📄 tabledlg.java
字号:
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.TableTreeViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.TableTree;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.Tree;
import com.swtdesigner.SWTResourceManager;
public class TableDlg extends Dialog {
private Table table;
protected Object result;
protected Shell shell;
/**
* Create the dialog
* @param parent
* @param style
*/
public TableDlg(Shell parent, int style) {
super(parent, style);
}
/**
* Create the dialog
* @param parent
*/
public TableDlg(Shell parent) {
this(parent, SWT.NONE);
}
/**
* Open the dialog
* @return the result
*/
public Object open() {
createContents();
shell.open();
shell.layout();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
return result;
}
/**
* Create contents of the dialog
*/
protected void createContents() {
shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
shell.setImage(SWTResourceManager.getImage(TableDlg.class, "/EVGREEN.JPG"));
shell.setSize(528, 472);
shell.setText("SWT Dialog");
table = new Table(shell, SWT.BORDER);
TableColumn tc1=new TableColumn(table,SWT.CENTER);
TableColumn tc2=new TableColumn(table,SWT.CENTER);
TableColumn tc3=new TableColumn(table,SWT.CENTER);
TableColumn tc4=new TableColumn(table,SWT.CENTER);
tc1.setText("用户名");
tc2.setText("国籍");
tc3.setText("年龄");
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setBounds(81, 43, 312, 220);
//
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -