Buggy code:
public class TreeColumn extends Item { Tree parent ; String displayText = "" ; int width ; int itemImageWidth ; boolean moveable ; boolean resizable = true ; int sort = SWT . NONE ; String toolTipText ; public TreeColumn ( Tree parent , int style ) { } public TreeColumn ( Tree parent , int style , int index ) { } public void addControlListener ( ControlListener listener ) { } public void addSelectionListener ( SelectionListener listener ) { } static Tree checkNull ( Tree tree ) { } static int checkStyle ( int style ) { } protected void checkSubclass ( ) { } void computeDisplayText ( GC gc ) { int availableWidth = ( width ) - ( 2 * ( parent . getHeaderPadding ( ) ) ) ; if ( ( image ) != null ) { availableWidth -= image . getBounds ( ) . width ; availableWidth -= Tree . MARGIN_IMAGE ; } if ( ( sort ) != ( SWT . NONE ) ) { availableWidth -= parent . arrowBounds . width ; availableWidth -= Tree . MARGIN_IMAGE ; } String text = this . text ; int textWidth = gc . textExtent ( text , DRAW_MNEMONIC ) . x ; if ( textWidth <= availableWidth ) { displayText = text ; return ; } int ellipsisWidth = gc . stringExtent ( ELLIPSIS ) . x ; availableWidth -= ellipsisWidth ; if ( availableWidth <= 0 ) { displayText = Tree . ELLIPSIS ; return ; } <START_BUG> int index = availableWidth // ( gc . getFontMetrics ( ) . getAverageCharWidth ( ) ) ; <END_BUG> textWidth = gc . textExtent ( text . substring ( 0 , index ) , DRAW_MNEMONIC ) . x ; if ( availableWidth == textWidth ) { displayText = ( text . substring ( 0 , index ) ) + ( Tree . ELLIPSIS ) ; return ; } if ( availableWidth < textWidth ) { do { index -- ; if ( index < 0 ) { displayText = Tree . ELLIPSIS ; return ; } text = text . substring ( 0 , index ) ; textWidth = gc . textExtent ( text , DRAW_MNEMONIC ) . x ; } while ( availableWidth < textWidth ) ; displayText = text + ( Tree . ELLIPSIS ) ; return ; } while ( textWidth < availableWidth ) { index ++ ; textWidth = gc . textExtent ( text . substring ( 0 , index ) , DRAW_MNEMONIC ) . x ; } displayText = ( text . substring ( 0 , ( index - 1 ) ) ) + ( Tree . ELLIPSIS ) ; } public void dispose ( ) { } void dispose ( boolean notifyParent ) { } public int getAlignment ( ) { } int getContentWidth ( GC gc , boolean useDisplayText ) { } int getIndex ( ) { } public boolean getMoveable ( ) { } int getOrderIndex ( ) { } public Tree getParent ( ) { } int getPreferredWidth ( ) { } public boolean getResizable ( ) { } public String getToolTipText ( ) { } public int getWidth ( ) { } int getX ( ) { } void paint ( GC gc ) { } public void pack ( ) { } public void removeControlListener ( ControlListener listener ) { } public void removeSelectionListener ( SelectionListener listener ) { } public void setAlignment ( int alignment ) { } public void setImage ( Image value ) { } public void setMoveable ( boolean moveable ) { } public void setResizable ( boolean value ) { } void setSortDirection ( int value ) { } public void setText ( String value ) { } public void setToolTipText ( String string ) { } public void setWidth ( int value ) { } void updateWidth ( GC gc ) { } void updateFont ( GC gc ) { } }

Fix:
int index = Math . min ( ( availableWidth // ( gc . getFontMetrics ( ) . getAverageCharWidth ( ) ) ) , text . length ( ) ) ;