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

📄 commoncontrolsample.java

📁 Eclipse RCP应用系统开发方法与实战源代码
💻 JAVA
字号:
package rcpbook.swtjface.sample;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class CommonControlSample {

	public static void main(String[] args) {
		final Display display = Display.getDefault();
		final Shell shell = new Shell();
		shell.setSize(300, 240);
		shell.setText("常用组件");
		shell.setLayout(new GridLayout(4, false));
		createContents(shell);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

	private static void createContents(Shell shell) {
		// 标签和文本框
		new Label(shell, SWT.NONE).setText("用户名");
		new Text(shell, SWT.BORDER).setTextLimit(10);
		new Label(shell, SWT.NONE).setText("密 码");
		Text pwd = new Text(shell, SWT.BORDER);
		pwd.setTextLimit(10);
		pwd.setEchoChar('*');
		// 按钮
		new Button(shell, SWT.PUSH).setText("退出");
		new Button(shell, SWT.CHECK).setText("足球");
		new Button(shell, SWT.CHECK).setText("电影");
		final Button button = new Button(shell, SWT.NONE);
		button.setText("测试按钮");

		String[] city = { "湖北武汉", "湖南长沙", "江西南昌", "江苏南京", "浙江杭州", "河南郑州",
				"广东广州", "广西南宁" };
		// 列表框
		List list = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
		for (int i = 0, n = city.length; i < n; i++) {
			list.add(city[i]);
		}
		list.select(0);
		// 组合框
		Combo combo = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
		combo.setItems(city);

	}
}

⌨️ 快捷键说明

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