?? sendmessagedialog.java
字號:
package com.face;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* 自定義對話框類
* @param parent
* @return
*/
public class SendMessageDialog extends Dialog {
private String textValue; //文本框內(nèi)容
private Text writeText; //文本實例
/**
* 構(gòu)造函數(shù)
* @param parentShell
*/
public SendMessageDialog(Shell parentShell) {
super(parentShell);
}
/**
* 構(gòu)建Dialog中的界面內(nèi)容
* @param parent
* @return
*/
protected Control createDialogArea(Composite parent) {
Composite topComp = new Composite(parent, SWT.NONE);
topComp.setLayout(new RowLayout());
new Label(topComp, SWT.NONE).setText("請輸入:");
writeText = new Text(topComp, SWT.BORDER|SWT.V_SCROLL|SWT.WRAP);
writeText.setLayoutData(new RowData(350, 200));
writeText.setText(textValue == null ?"" :textValue);
return topComp;
}
/**
* 可以改變窗口的默認樣式
*/
protected int getShellStyle() {
return super.getShellStyle()|SWT.MAX;
}
/**
* 取得文本內(nèi)容
* @return String 文本內(nèi)容
*/
protected String getTextValue() {
return this.textValue;
}
/**
* 設(shè)置文本內(nèi)容
* @param str 文本內(nèi)容
*/
protected void setTextValue(String str) {
this.textValue = str;
}
/**
* 單擊確定按鈕
*/
protected void buttonPressed(int buttonId) {
//如果點了OK按鈕,則將值取回變量
if(buttonId == IDialogConstants.OK_ID) {
textValue = writeText.getText();
}
super.buttonPressed(buttonId);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -