⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createactivitydialog.java

📁 swt带dnd应用的网址收藏夹源码
💻 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 + -