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

📄 custommessageview.java

📁 java eclipse rcp学习
💻 JAVA
字号:
/**
 * 
 */
package chainShopMS.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;
/**
 * @author Administrator
 *	会员顾客信息视图
 */
public class CustomMessageView extends ViewPart
{
	private Text customName;// 顾客姓名
	
	private Text customID;//顾客ID

	private Combo customSex;// 性别
	
	private Text customTel;// 联系方式

	private Text customAddr;// 住址
	
	private Text customNote;// 备注
	
	
	private Button search;// 查询

	private Button add;// 添加
	
	private Button update;// 修改
	
	private Button del;// 注销

	/** 该视图的ID */
	public static final String ID = "chainShopMS.views.CustomMessageView";

	/**
	 * 生成GridData对象的重复代码太多,写出一个可以减少程序的行数,用起来也方便,而且要注意一个GridData只能呗一个组件实验
	 * 不能两个组件使用一个GridData,否则一个组件不会显示出来
	 */
	private GridData createGridData(int style,int horizontalSpan)
	{
		GridData gridData=new GridData(style);
		gridData.horizontalSpan=horizontalSpan;
		gridData.grabExcessHorizontalSpace=true;
		gridData.horizontalAlignment=SWT.FILL;
		return gridData;
	}
	
	// 必须实现的两个方法
	public void createPartControl(final Composite parent)
	{
		parent.setLayout(new GridLayout(4, false));// 信息面板分成6列

		new Label(parent, SWT.NONE).setText("编    号:");
		customID = new Text(parent, SWT.BORDER);
		customID.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL,1));

		new Label(parent, SWT.NONE).setText("姓    名:");
		customName = new Text(parent, SWT.BORDER);
		customName.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL,1));

		new Label(parent, SWT.NONE).setText("性    别:");
		customSex = new Combo(parent, SWT.BORDER);
		customSex.add("男");
		customSex.add("女");
		customSex.select(1);//默认为女
		customSex.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL,1));
		
		new Label(parent, SWT.NONE).setText("联系方式:");
		customTel = new Text(parent, SWT.BORDER);
		customTel.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL,1));
		
		new Label(parent, SWT.NONE).setText("住    址:");
		customAddr = new Text(parent, SWT.BORDER);
		customAddr.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL,1));
		
		new Label(parent, SWT.NONE).setText("备    注:");
		customNote = new Text(parent, SWT.BORDER);
		customNote.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL,1));
		
		
		
		search =new Button(parent,SWT.NONE);
		search.setText("  查询  ");
		
		add =new Button(parent,SWT.NONE);
		add.setText("  添加  ");
		
		update =new Button(parent,SWT.NONE);
		update.setText("  修改  ");
		
		del =new Button(parent,SWT.NONE);
		del.setText("  注销  ");
	}

	public void setFocus()
	{
		customID.setFocus();
	}
}

⌨️ 快捷键说明

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