Buggy code:
void destroyItem ( TreeColumn column ) { } void destroyItem ( TreeItem item ) { } int drawItemProc ( int browser , int id , int property , int itemState , int theRect , int gdDepth , int colorDevice ) { } void fixScrollBar ( ) { } int getBorder ( ) { } int getCheckColumnWidth ( ) { } public Rectangle getClientArea ( ) { } public TreeColumn getColumn ( int index ) { } public int getColumnCount ( ) { } public int [ ] getColumnOrder ( ) { } public TreeColumn [ ] getColumns ( ) { } int getGap ( ) { } public int getGridLineWidth ( ) { } public int getHeaderHeight ( ) { } public boolean getHeaderVisible ( ) { } int getLeftDisclosureInset ( int column_id ) { } int getInsetWidth ( int column_id , boolean leftInset ) { } public TreeItem getItem ( int index ) { } public TreeItem getItem ( Point point ) { } public int getItemCount ( ) { } int getItemCount ( TreeItem parentItem ) { } public int getItemHeight ( ) { } public TreeItem [ ] getItems ( ) { } TreeItem [ ] getItems ( TreeItem parentItem ) { } public boolean getLinesVisible ( ) { } public TreeItem getParentItem ( ) { } public TreeItem [ ] getSelection ( ) { } int getSelection ( TreeItem [ ] result , int item , int ptr , int index ) { } public int getSelectionCount ( ) { } public TreeColumn getSortColumn ( ) { } public int getSortDirection ( ) { } public TreeItem getTopItem ( ) { } int helpProc ( int inControl , int inGlobalMouse , int inRequest , int outContentProvided , int ioHelpContent ) { } int hitTestProc ( int browser , int id , int property , int theRect , int mouseRect ) { } void hookEvents ( ) { } public int indexOf ( TreeColumn column ) { } public int indexOf ( TreeItem item ) { } int _indexOf ( TreeItem parentItem , TreeItem item ) { } int itemCompareProc ( int browser , int itemOne , int itemTwo , int sortProperty ) { } int itemDataProc ( int browser , int id , int property , int itemData , int setValue ) { } int itemNotificationProc ( int browser , int id , int message ) { } int kEventControlGetClickActivation ( int nextHandler , int theEvent , int userData ) { } int kEventControlSetCursor ( int nextHandler , int theEvent , int userData ) { } int kEventUnicodeKeyPressed ( int nextHandler , int theEvent , int userData ) { } int kEventMouseDown ( int nextHandler , int theEvent , int userData ) { } void releaseItem ( TreeItem item , boolean release ) { } void releaseItems ( int [ ] ids ) { } void releaseChildren ( boolean destroy ) { } void releaseWidget ( ) { } public void removeAll ( ) { } public void removeSelectionListener ( SelectionListener listener ) { } public void removeTreeListener ( TreeListener listener ) { } void resetVisibleRegion ( int control ) { } public void setInsertMark ( TreeItem item , boolean before ) { } public void selectAll ( ) { } void setBackground ( float [ ] color ) { } int setBounds ( int x , int y , int width , int height , boolean move , boolean resize , boolean events ) { } public void setColumnOrder ( int [ ] order ) { } void setFontStyle ( Font font ) { } public void setHeaderVisible ( boolean show ) { } public void setItemCount ( int count ) { } void setItemCount ( TreeItem parentItem , int count ) { } void setItemHeight ( int itemHeight ) { } void setItemHeight ( Image image ) { } public void setLinesVisible ( boolean show ) { } public void setRedraw ( boolean redraw ) { } boolean setScrollWidth ( TreeItem item ) { } boolean setScrollWidth ( boolean set ) { } boolean setScrollWidth ( boolean set , int [ ] childIds , boolean recurse ) { } public void setSelection ( TreeItem item ) { } public void setSelection ( TreeItem [ ] items ) { } public void setSortColumn ( TreeColumn column ) { } public void setSortDirection ( int direction ) { } public void setTopItem ( TreeItem item ) { checkWidget ( ) ; if ( item == null ) error ( ERROR_NULL_ARGUMENT ) ; if ( item . isDisposed ( ) ) error ( ERROR_INVALID_ARGUMENT ) ; showItem ( item , false ) ; int columnId = ( ( columnCount ) == 0 ) ? column_id : columns [ 0 ] . id ; OS . RevealDataBrowserItem ( handle , item . id , columnId , ( ( byte ) ( kDataBrowserRevealWithoutSelecting ) ) ) ; Rect rect = new Rect ( ) ; if ( ( OS . GetDataBrowserItemPartBounds ( handle , item . id , column_id , kDataBrowserPropertyEnclosingPart , rect ) ) == ( OS . noErr ) ) { int border = getBorder ( ) ; int [ ] top = new int [ 1 ] ; int [ ] left = new int [ 1 ] ; OS . GetDataBrowserScrollPosition ( handle , top , left ) ; <START_BUG> OS . SetDataBrowserScrollPosition ( handle , ( ( ( ( top [ 0 ] ) + ( rect . top ) ) - border ) - ( getHeaderHeight ( ) ) ) , left [ 0 ] ) ; <END_BUG> } } public void showColumn ( TreeColumn column ) { } public void showItem ( TreeItem item ) { } void showItem ( TreeItem item , boolean scroll ) { } public void showSelection ( ) { } int trackingProc ( int browser , int id , int property , int theRect , int startPt , int modifiers ) { } }

Fix:
OS . SetDataBrowserScrollPosition ( handle , Math . max ( 0 , ( ( ( ( top [ 0 ] ) + ( rect . top ) ) - border ) - ( getHeaderHeight ( ) ) ) ) , left [ 0 ] ) ;