textfactory.java

来自「利用 java SWT 实现MVC功能」· Java 代码 · 共 37 行

JAVA
37
字号
package ExampleViewer.common;


import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;

import ExampleViewer.form.FieldMode;


public class TextFactory  {

	/**
	 * @param parent
	 * @param mode
	 * @param layoutData	
	 */
	static public Text create(Composite parent, int style, Object layoutData,int mode) {
		if (mode == FieldMode.Read) {
			style = SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY;
		} else if (mode == FieldMode.Edit) {
			style = SWT.BORDER | SWT.V_SCROLL | SWT.WRAP;			
		} else if (mode == FieldMode.Preview) {
			style = SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY;			
		}

		Text text = new Text(parent, style);
		if (mode == FieldMode.Read || mode == FieldMode.Preview)
			text.setBackground(parent.getBackground());
		
		if (layoutData != null) text.setLayoutData(layoutData);

		return text;
	}
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?