?? wizarddialogclass.java
字號:
/**
*@author: WangJinTao,MengQingChang2006
*/
package jfaceDialog;
import org.eclipse.jface.window.*;
import org.eclipse.jface.wizard.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class WizardDialogClass extends ApplicationWindow {
private TableItem item;
private Table table;
public WizardDialogClass() {
// 部署窗口
super(null);
}
public void run() {
setBlockOnOpen(true);
open();
Display.getCurrent().dispose();
}
protected Control createContents(Composite parent) {
// 設(shè)置窗體標(biāo)題
getShell().setText("向?qū)υ捒驅(qū)嵗?quot;);
// /設(shè)置窗體大小
getShell().setSize(400, 200);
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
comp.setLayout(new GridLayout(2, false));
// 定義表格
table = new Table(comp, SWT.MULTI | SWT.FULL_SELECTION);
// 使表頭可見
table.setHeaderVisible(true);
// 使表格線可見
table.setLinesVisible(true);
// 對表格進(jìn)行布局
GridData grid = new GridData(GridData.FILL_BOTH);
grid.horizontalSpan = 2;
table.setLayoutData(grid);
// 定義表的列并設(shè)置列的寬度
TableColumn col1 = new TableColumn(table, SWT.NONE);
col1.setText("學(xué)號");
col1.setWidth(80);
TableColumn col2 = new TableColumn(table, SWT.NONE);
col2.setText("姓名");
col2.setWidth(80);
TableColumn col3 = new TableColumn(table, SWT.NONE);
col3.setText("性別");
col3.setWidth(80);
TableColumn col4 = new TableColumn(table, SWT.NONE);
col4.setText("郵箱");
col4.setWidth(120);
TableColumn col5 = new TableColumn(table, SWT.NONE);
col5.setText("自我評價(jià)");
col5.setWidth(120);
Button addButton = new Button(comp, SWT.PUSH);
addButton.setText("注冊信息");
addButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
item = new TableItem(table, SWT.NONE);
StudentWizardInformation wizard = new StudentWizardInformation(
item);
WizardDialog dialog = new WizardDialog(getShell(), wizard);
// 設(shè)置對話框所有頁的大小,
dialog.setPageSize(-1, 105);
dialog.open();
}
});
// 對“注冊信息”按鈕進(jìn)行布局
GridData gridAdd = new GridData(GridData.HORIZONTAL_ALIGN_END);
gridAdd.widthHint = 100;
addButton.setLayoutData(gridAdd);
Button ExitButton = new Button(comp, SWT.PUSH);
ExitButton.setText("退出");
ExitButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getShell().dispose();
}
});
// 對“退出”按鈕進(jìn)行布局
GridData gridExit = new GridData();
gridExit.widthHint = 100;
ExitButton.setLayoutData(gridExit);
return comp;
}
public static void main(String[] args) {
new WizardDialogClass().run();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -