Tuesday, April 21, 2009

Check box tree in SWT

Below is a small snippet of code for creating a checked tree in SWT

tree = new Tree(composite, SWT.CHECK | SWT.BORDER);
// Turn off drawing to avoid flicker
tree.setRedraw(false);
for(int i = 0; i<5>
TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText("TreeItem" + i);
item.setChecked(true);
item.setExpanded(true);
for ( int j =0; j <>
TreeItem child = new TreeItem(item, SWT.NONE);
child.setText("TreeItem" + i + "." + j);
child.setChecked(true);
child.setExpanded(true);
}
}
// Turn drawing back on!
tree.setRedraw(true);

No comments:

Post a Comment