Project: SWT
Bug 131623 Tree selected column bgcolour does not draw on empty rows when setting a tree background colour
Reported: 2006-03-13 19:39:25 | Status: resolved fixed

SWT Win32 CVS Without the call to tree.setBackground(), the selected column background color fills in all empty rows at the bottom of the tree. With it, the rows are not filled in with the select column background colour. The table widget fills it in properly. public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final int columns = 5; final int itemCount = 15; final Tree tree = new Tree(shell, SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.MULTI); tree.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); for (int i = 0; i < columns; i++) new TreeColumn(tree, SWT.LEFT).setWidth(75); tree.setHeaderVisible(true); tree.setLinesVisible(true); tree.setSortDirection(SWT.DOWN); tree.setSortColumn(tree.getColumn(0)); tree.addListener(SWT.SetData, new Listener() { public void handleEvent(Event event) { TreeItem item = (TreeItem) event.item; int index = event.index; TreeItem parentItem = item.getParentItem(); String text = null; if (parentItem == null) { text = "node " + tree.indexOf(item); } else { text = parentItem.getText() + " - " + parentItem.indexOf(item); } for (int i = 0; i < columns; i++) { item.setText(i, text); } if (index % 2 == 0) { Color c = display.getSystemColor(SWT.COLOR_DARK_YELLOW); item.setBackground(c); } item.setItemCount(itemCount); } }); final Table table = new Table(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); table.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); for (int i = 0; i < columns; i++) new TableColumn(table, SWT.LEFT).setWidth(75); table.setLinesVisible(true); table.setHeaderVisible(true); table.setSortDirection(SWT.DOWN); table.setSortColumn(table.getColumn(0)); table.addListener(SWT.SetData, new Listener() { public void handleEvent(Event event) { TableItem item = (TableItem) event.item; int index = event.index; String text = null; text = "node " + index; for (int i = 0; i < columns; i++) { item.setText(i, text); } if (index % 2 == 0) { Color c = display.getSystemColor(SWT.COLOR_DARK_YELLOW); item.setBackground(c); } } }); final int timerDelay = 1250; final Runnable r = new Runnable() { public void run() { if (c++ >= columns - 1) c = 0; int dir = table.getSortDirection() == SWT.DOWN ? SWT.UP : SWT.DOWN; tree.setItemCount(itemCount); table.setItemCount(itemCount); table.setSortDirection(dir); table.setSortColumn(table.getColumn(c)); tree.setSortColumn(tree.getColumn(c)); tree.setSortDirection(dir); display.timerExec(timerDelay, this); } }; display.timerExec(timerDelay, r); shell.setSize(800, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java