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

📄 test5.java

📁 生成与Oracle相关的Ibatis相关配置文件及Java源码
💻 JAVA
字号:
/*
 * Copyright (c) 2008 胜利油田胜利软件有限责任公司. All rights reserved.
 */
package org.test;

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.custom.*;

/**
 * 
 * @author 于景洋
 * @newtime Oct 29, 2008,12:34:46 PM
 * @version 1.0
 * @see
 * @since JDK 1.5.0
 */
public class test5 {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		final Table table = new Table(shell, SWT.FULL_SELECTION | SWT.BORDER);
		table.setLinesVisible(true);

		table.setHeaderVisible(true);
		String[] titles = { "列名", "选择" };

		TableColumn column1 = new TableColumn(table, SWT.NONE);
		column1.setText(titles[0]);
		column1.setWidth(50);
		TableColumn column2 = new TableColumn(table, SWT.NONE);
		column2.setText(titles[1]);
		column2.setWidth(50);
		column1.pack();

		for (int i = 0; i < 10; i++) {
			TableItem item = new TableItem(table, SWT.NULL);
			item.setText(0, "x" + String.valueOf(i));

		}

		final TableItem[] items = table.getItems();
		// final Button[] button=new Button[items.length];
		for (int i = 0; i < items.length; i++) {
			TableEditor editor = new TableEditor(table);
			editor.horizontalAlignment = SWT.CENTER;
			editor.grabHorizontal = false;
			editor.minimumWidth = 12;
			final TableItem currentItem = items[i];
			final Button b = new Button(table, SWT.CHECK);

			b.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
			b.setVisible(true);

			b.addSelectionListener(new SelectionAdapter() {
				public void widgetSelected(SelectionEvent e) {
					if (e.getSource() == (Object) b)
						if (b.getSelection() == true) {

							System.out.println("selected"
									+ currentItem.getText());

						} else {
							System.out.println("unselected"
									+ currentItem.getText());
						}

				}
			});
			TableItem tableItem = items[i];
			editor.setEditor(b, tableItem, 1);
			// table.redraw();
		}

		table.setSize(table.computeSize(400, 400));
		// table.pack();
		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();

	}
}

⌨️ 快捷键说明

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