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

📄 tablesample.java

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

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

public class TableSample {
	public static void main(String[] args) {
		final Display display = Display.getDefault();
		final Shell shell = new Shell();
		shell.setSize(280, 180);
		shell.setText("表格Table示例");
		shell.setLayout(new FillLayout());
		createContents(shell);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

	private static void createContents(Shell shell) {
		Table table = new Table(shell, SWT.CHECK | SWT.FULL_SELECTION);
		table.setHeaderVisible(true);
		table.setLinesVisible(true);
		table.setRedraw(false);
		TableColumn tableColumn1 = new TableColumn(table, SWT.NONE);
		tableColumn1.setText("学号");
		tableColumn1.setWidth(80);
		TableColumn tableColumn2 = new TableColumn(table, SWT.NONE);
		tableColumn2.setText("姓名");
		tableColumn2.setWidth(80);
		TableColumn tableColumn3 = new TableColumn(table, SWT.NONE);
		tableColumn3.setText("专业");
		tableColumn3.setWidth(80);
		for (int i = 0; i < 8; i++) {
			TableItem item = new TableItem(table, SWT.NONE);
			item.setText(0, i + "_column1");
			item.setText(1, (i + 1) + "_column2");
			item.setText(2, (i + 2) + "_column3");
		}
		table.setRedraw(true);
	}
}

⌨️ 快捷键说明

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