?? createactivitydialog.java
字號:
package cn.com.javachen.myxml.dialog;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
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.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class CreateActivityDialog extends Dialog {
private String textValue= "";
private Text text;
public String getTextValue() {
return this.textValue;
}
public void setTextValue(String text) {
this.textValue = text;
}
public CreateActivityDialog(Shell shell) {
super(shell);
}
protected void configureShell(Shell shell,String title) {
super.configureShell(shell);
if (title != null)
shell.setText(title);
}
// construct the userface of dialog
protected Control createDialogArea(Composite parent) {
Composite topComp = new Composite(parent, SWT.NONE);;
topComp.setLayout(new RowLayout());
new Label(topComp, SWT.NONE).setText("請輸入:");
text = new Text(topComp, SWT.BORDER);
text.setText(textValue == null ? "" : textValue);
text.setLayoutData(new RowData(100, -1));
return parent;
}
/**
* 重載這個方法可以改變窗口的默認式樣 SWT.RESIZE:窗口可以拖動邊框改變大小 SWT.MAX: 窗口可以最大化
*/
protected int getShellStyle() {
return super.getShellStyle() | SWT.RESIZE | SWT.MAX;
}
protected Point getInitialSize() {
Point p = super.getInitialSize();
p.x = 400;
p.y = 200;
return p;
}
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
textValue = text.getText();
}
super.buttonPressed(buttonId);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -