Buggy code:
public void addSelectionListener ( SelectionListener listener ) { } public void addTreeListener ( TreeListener listener ) { } static int checkStyle ( int style ) { } int computeColumnIntersect ( int x , int startColumn ) { } public Point computeSize ( int wHint , int hHint , boolean changed ) { } void createItem ( TreeColumn column , int index ) { } void createItem ( TreeItem item , int index ) { } public void deselectAll ( ) { } void destroyItem ( TreeColumn column ) { } void destroyItem ( TreeItem item ) { } TreeItem [ ] getAllItems ( ) { } int getCellPadding ( ) { } Image getCheckmarkImage ( ) { } public Control [ ] getChildren ( ) { } Image getCollapsedImage ( ) { } public TreeColumn getColumn ( int index ) { } public int getColumnCount ( ) { } public TreeColumn [ ] getColumns ( ) { } Color getConnectorColor ( ) { } Image getExpandedImage ( ) { } Image getGrayUncheckedImage ( ) { } public int getGridLineWidth ( ) { } public int getHeaderHeight ( ) { } int getHeaderPadding ( ) { } public boolean getHeaderVisible ( ) { } public TreeItem getItem ( Point point ) { } public TreeItem getItem ( int index ) { } public int getItemCount ( ) { } public int getItemHeight ( ) { } public TreeItem [ ] getItems ( ) { } int getItemY ( TreeItem item ) { } public boolean getLinesVisible ( ) { } public TreeItem getParentItem ( ) { } public TreeItem [ ] getSelection ( ) { } public int getSelectionCount ( ) { } int getSelectionIndex ( TreeItem item ) { } public TreeItem getTopItem ( ) { } Image getUncheckedImage ( ) { } void handleEvents ( Event event ) { } void headerOnMouseDoubleClick ( Event event ) { } void headerOnMouseDown ( Event event ) { } void headerOnMouseExit ( ) { } void headerOnMouseMove ( Event event ) { } void headerOnMouseUp ( Event event ) { } void headerOnPaint ( Event event ) { } void headerPaintHShadows ( GC gc , int x , int y , int width , int height ) { } void headerPaintVShadows ( GC gc , int x , int y , int width , int height ) { } public int indexOf ( TreeColumn column ) { } public int indexOf ( TreeItem item ) { } static void initImages ( final Display display ) { } void makeAvailable ( TreeItem item ) { } void makeDescendentsAvailable ( TreeItem item , TreeItem [ ] descendents ) { } void makeDescendentsUnavailable ( TreeItem item , TreeItem [ ] descendents ) { } void onArrowDown ( int stateMask ) { } void onArrowLeft ( int stateMask ) { } void onArrowRight ( int stateMask ) { } void onArrowUp ( int stateMask ) { } void onCR ( ) { } void onDispose ( ) { } void onEnd ( int stateMask ) { } void onFocusIn ( ) { } void onFocusOut ( ) { } void onHome ( int stateMask ) { } void onKeyDown ( Event event ) { } void onMouseDoubleClick ( Event event ) { } void onMouseDown ( Event event ) { if ( ! ( isFocusControl ( ) ) ) <START_BUG> setFocus ( ) ; <END_BUG> int index = ( ( ( event . y ) - ( getHeaderHeight ( ) ) ) // ( itemHeight ) ) + ( topIndex ) ; if ( ! ( ( 0 <= index ) && ( index < ( availableItemsCount ) ) ) ) return ; TreeItem selectedItem = availableItems [ index ] ; if ( ( ( selectedItem . items . length ) > 0 ) && ( selectedItem . getExpanderBounds ( ) . contains ( event . x , event . y ) ) ) { if ( ( event . button ) != 1 ) return ; boolean expand = ! ( selectedItem . expanded ) ; selectedItem . setExpanded ( expand ) ; Event newEvent = new Event ( ) ; newEvent . item = selectedItem ; if ( expand ) { inExpand = true ; sendEvent ( Expand , newEvent ) ; inExpand = false ; if ( isDisposed ( ) ) return ; if ( ( selectedItem . items . length ) == 0 ) { selectedItem . expanded = false ; } } else { sendEvent ( Collapse , newEvent ) ; } return ; } if ( ( ( ( style ) & ( SWT . CHECK ) ) != 0 ) && ( selectedItem . getCheckboxBounds ( ) . contains ( event . x , event . y ) ) ) { if ( ( event . button ) != 1 ) return ; selectedItem . setChecked ( ( ! ( selectedItem . checked ) ) ) ; Event newEvent = new Event ( ) ; newEvent . item = selectedItem ; newEvent . detail = SWT . CHECK ; postEvent ( Selection , newEvent ) ; return ; } if ( ! ( selectedItem . getHitBounds ( ) . contains ( event . x , event . y ) ) ) return ; if ( ( ( ( event . stateMask ) & ( SWT . SHIFT ) ) == 0 ) && ( ( event . keyCode ) != ( SWT . SHIFT ) ) ) anchorItem = null ; if ( ( ( style ) & ( SWT . SINGLE ) ) != 0 ) { if ( ! ( selectedItem . isSelected ( ) ) ) { if ( ( event . button ) == 1 ) { selectItem ( selectedItem , false ) ; setFocusItem ( selectedItem , true ) ; redrawItem ( selectedItem . availableIndex , true ) ; Event newEvent = new Event ( ) ;

Fix:
forceFocus ( ) ;