?? wizardpageone.java
字號:
/**
*@author: WangJinTao,MengQingChang2006
*/
package jfaceDialog;
import org.eclipse.jface.wizard.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.jface.dialogs.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class WizardPageOne extends WizardPage implements ModifyListener {
private Text textID;
private Text textName;
private Combo combo;
private Text textEmail;
private GridData grid;
protected WizardPageOne() {
super("");
setTitle("添加學生基本信息");
setMessage("注意:請正確填寫如下信息!", IMessageProvider.INFORMATION);
}
public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
comp.setLayout(new GridLayout(2, false));
// 定制“學號”標簽
new Label(comp, SWT.NONE).setText("學號:");
// 定制“學號”文本框
textID = new Text(comp, SWT.BORDER);
grid = new GridData(GridData.FILL_HORIZONTAL);
textID.setLayoutData(grid);
textID.addModifyListener(this);
// 定制“姓名”標簽
new Label(comp, SWT.NONE).setText("姓名:");
// 定制“姓名”文本框
textName = new Text(comp, SWT.BORDER);
grid = new GridData(GridData.FILL_HORIZONTAL);
textName.setLayoutData(grid);
textName.addModifyListener(this);
// 定制“性別”標簽
new Label(comp, SWT.NONE).setText("性別:");
combo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
combo.setItems(new String[] { "男", "女" });
grid = new GridData(GridData.FILL_HORIZONTAL);
combo.setLayoutData(grid);
combo.addModifyListener(this);
// 定制“Email”標簽
new Label(comp, SWT.None).setText("Email:");
// 定制“Email”文本框
textEmail = new Text(comp, SWT.BORDER);
grid = new GridData(GridData.FILL_HORIZONTAL);
textEmail.setLayoutData(grid);
textEmail.addModifyListener(this);
setControl(comp);
}
public String getID() {
return textID.getText();
}
public String getName() {
return textName.getText();
}
public String getCombo() {
int index = combo.getSelectionIndex();
if (index == -1) {
return "";
}
return combo.getItem(index);
}
public String getEmail() {
return textEmail.getText();
}
// 監(jiān)聽數(shù)據(jù)輸入合法性
public void modifyText(ModifyEvent e) {
if (getID().length() == 0) {
setMessage("注意:學號項不能為空!!!", IMessageProvider.WARNING);
return;
}
if (getName().length() == 0) {
setMessage("注意:姓名項不能為空!!!", IMessageProvider.WARNING);
return;
}
if (getCombo().length() == 0) {
setMessage("注意:性別項不能為空!!!", IMessageProvider.WARNING);
return;
}
if (getEmail().length() == 0 || getEmail().indexOf("@") < 0) {
setMessage("注意:Email格式錯或Email項為空", IMessageProvider.ERROR);
return;
}
// 消除錯誤提示信息
setMessage(null);
// 使完成按鈕處于激活狀態(tài)
setPageComplete(true);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -