public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
		RowLayout layout = new RowLayout (SWT.VERTICAL);
		layout.fill = true;
		layout.wrap = false;
		shell.setLayout (layout);
		final Tree tree = new Tree (shell, SWT.NONE);
		for (int i=0; i<32; i++) {
			TreeItem item0 = new TreeItem (tree, SWT.NONE);
			item0.setText ("Item " + i + " is quite long");
			for (int j=0; j<3; j++) {
				TreeItem item1 = new TreeItem (item0, SWT.NONE);
				item1.setText ("Item " + i + " " + j + " is quite long");
				for (int k=0; k<3; k++) {
					TreeItem item2 = new TreeItem (item1, SWT.NONE);
					item2.setText ("Item " + i + " " + j + " " + k + " is quite long");	
					for (int l=0; l<3; l++) {
						TreeItem item3 = new TreeItem (item2, SWT.NONE);
						item3.setText ("Item " + i + " " + j + " " + k + " " + l + " is quite long");
					}
				}
			}
		}
		tree.setLayoutData(new RowData (200, 200));
		final Button button = new Button (shell, SWT.PUSH);
		button.setText ("Visible Items []");
		button.addListener (SWT.Selection, new Listener () {
			@Override
			public void handleEvent (Event e) {
				int visibleCount = 0;
				Rectangle rect = tree.getClientArea ();
				TreeItem item = tree.getTopItem ();
				while (item != null) {
					visibleCount++;
					Rectangle itemRect = item.getBounds();
					if (itemRect.y + itemRect.height > rect.y + rect.height) {
						break;
					}
					item = nextItem (tree, item);
				}				
				button.setText ("Visible Items [" + visibleCount + "]");
			}
		});
		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
		display.dispose();
	}