Buggy code:
public class CTabItem extends Item { CTabFolder parent ; int x ; int y ; int width ; int height = 0 ; Control control ; String toolTipText ; String shortenedText ; int shortenedTextWidth ; Font font ; Image disabledImage ; Rectangle closeRect = new Rectangle ( 0 , 0 , 0 , 0 ) ; int closeImageState = SWT . BACKGROUND ; boolean showClose = false ; boolean showing = false ; public CTabItem ( CTabFolder parent , int style ) { } public CTabItem ( CTabFolder parent , int style , int index ) { } public void dispose ( ) { } public Rectangle getBounds ( ) { } public Control getControl ( ) { } public Image getDisabledImage ( ) { } public Font getFont ( ) { } public CTabFolder getParent ( ) { } public boolean getShowClose ( ) { } public String getToolTipText ( ) { } public boolean isShowing ( ) { } public void setControl ( Control control ) { } public void setDisabledImage ( Image image ) { } public void setFont ( Font font ) { } public void setImage ( Image image ) { checkWidget ( ) ; if ( ( image != null ) && ( image . isDisposed ( ) ) ) { SWT . error ( ERROR_INVALID_ARGUMENT ) ; } Image oldImage = getImage ( ) ; if ( ( image == null ) && ( oldImage == null ) ) return ; if ( ( image != null ) && ( image . equals ( oldImage ) ) ) return ; super . setImage ( image ) ; if ( ! ( parent . updateTabHeight ( false ) ) ) { if ( ( oldImage != null ) && ( image != null ) ) { Rectangle oldBounds = oldImage . getBounds ( ) ; Rectangle bounds = image . getBounds ( ) ; if ( ( ( bounds . width ) == ( oldBounds . width ) ) && ( ( bounds . height ) == ( oldBounds . height ) ) ) { if ( showing ) { int index = parent . indexOf ( this ) ; boolean selected = index == ( parent . selectedIndex ) ; if ( selected || ( parent . showUnselectedImage ) ) { CTabFolderRenderer renderer = parent . renderer ; Rectangle trim = renderer . computeTrim ( index , NONE , 0 , 0 , 0 , 0 ) ; int imageX = ( x ) - ( trim . x ) ; int maxImageWidth ; if ( selected ) { GC gc = new GC ( parent ) ; if ( ( parent . single ) && ( ( parent . showClose ) || ( showClose ) ) ) { <START_BUG> imageX += renderer . computeSize ( PART_CLOSE_BUTTON , NONE , gc ) . x ; <END_BUG> } int rightEdge = Math . min ( ( ( x ) + ( width ) ) , parent . getRightItemEdge ( gc ) ) ; gc . dispose ( ) ; maxImageWidth = ( rightEdge - imageX ) - ( ( trim . width ) + ( trim . x ) ) ; if ( ( ! ( parent . single ) ) && ( ( closeRect . width ) > 0 ) ) maxImageWidth -= ( closeRect . width ) + ( CTabFolderRenderer . INTERNAL_SPACING ) ; } else { maxImageWidth = ( ( ( x ) + ( width ) ) - imageX ) - ( ( trim . width ) + ( trim . x ) ) ; if ( ( parent . showUnselectedClose ) && ( ( parent . showClose ) || ( showClose ) ) ) { maxImageWidth -= ( closeRect . width ) + ( CTabFolderRenderer . INTERNAL_SPACING ) ; } } if ( ( bounds . width ) < maxImageWidth ) { int imageY = ( ( y ) + ( ( ( height ) - ( bounds . height ) ) // 2 ) ) + ( parent . onBottom ? - 1 : 1 ) ; parent . redraw ( imageX , imageY , bounds . width , bounds . height , false ) ; } } } return ; } } parent . updateItems ( ) ; parent . redrawTabs ( ) ; } } public void setShowClose ( boolean close ) { } public void setText ( String string ) { } public void setToolTipText ( String string ) { } }

Fix:
imageX += renderer . computeSize ( PART_CLOSE_BUTTON , NONE , gc , DEFAULT , DEFAULT ) . x ;