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

📄 virtualtable.java

📁 自己建立的项目
💻 JAVA
字号:
package com.swtSample.advancedControl;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
 * This class demonstrates the SWT.VIRTUAL style
 */
public class VirtualTable {
	private String[] items;

	/**
	 * Runs the application
	 */
	public void run() {
		// Create the data for the table
		items = new String[5000];
		for (int i = 0, n = items.length; i < n; i++) {
			items[i] = "I am item number " + i;
		}
		
		// Normal SWT stuff
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setText("Virtual Table");
		createContents(shell);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}
	
	/**
	 * Creates the shell's contents
	 * @param shell the shell
	 */
	private void createContents(Shell shell) {
		shell.setLayout(new FillLayout());
		
		// Create a table and column
		final Table table = new Table(shell, SWT.VIRTUAL);
		table.setLinesVisible(true);
		table.setHeaderVisible(true);
		TableColumn tc = new TableColumn(table, SWT.NONE);
		tc.setText("Virtual Value");
		tc.setWidth(400);

		// Tell the table how many items it has
		table.setItemCount(items.length);
		
		// Provide the callback handler--this handler
		// is invoked when the table needs new rows
		table.addListener(SWT.SetData, new Listener() {
			public void handleEvent(Event event) {
				TableItem item = (TableItem) event.item;
				item.setText(items[table.indexOf(item)]);
			}
		});
	}

	/**
	 * The application entry point
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		new VirtualTable().run();
	}
}

⌨️ 快捷键说明

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