Buggy code:
public class LayoutTreeNode extends LayoutTree { static class ChildSizes { int left ; int right ; public ChildSizes ( int l , int r ) { } } private LayoutTree [ ] children = new LayoutTree [ 2 ] ; static final int SASH_WIDTH = 3 ; public LayoutTreeNode ( LayoutPartSash sash ) { } public LayoutPart findPart ( Point toFind ) { } public LayoutPart computeRelation ( ArrayList relations ) { } public void disposeSashes ( ) { } public LayoutTree find ( LayoutPart child ) { } public LayoutPart findBottomRight ( ) { } public LayoutTreeNode findCommonParent ( LayoutPart child1 , LayoutPart child2 ) { } LayoutTreeNode findCommonParent ( LayoutPart child1 , LayoutPart child2 , boolean foundChild1 , boolean foundChild2 ) { } public LayoutTreeNode findSash ( LayoutPartSash sash ) { } void findSashes ( LayoutTree child , PartPane . Sashes sashes ) { } public LayoutPartSash getSash ( ) { } public boolean isVisible ( ) { } LayoutTree remove ( LayoutTree child ) { } void replaceChild ( LayoutTree oldChild , LayoutTree newChild ) { } public boolean sameDirection ( boolean isVertical , LayoutTreeNode subTree ) { } public int doComputePreferredSize ( boolean width , int availableParallel , int availablePerpendicular , int preferredParallel ) { } LayoutTreeNode . ChildSizes computeChildSizes ( int width , int height , int left , int right , int preferredWidth ) { Assert . isTrue ( children [ 0 ] . isVisible ( ) ) ; Assert . isTrue ( children [ 1 ] . isVisible ( ) ) ; assertValidSize ( width ) ; assertValidSize ( height ) ; assertValidSize ( preferredWidth ) ; Assert . isTrue ( ( left >= 0 ) ) ; Assert . isTrue ( ( right >= 0 ) ) ; Assert . isTrue ( ( preferredWidth >= 0 ) ) ; Assert . isTrue ( ( preferredWidth <= width ) ) ; boolean vertical = getSash ( ) . isVertical ( ) ; if ( width <= ( LayoutTreeNode . SASH_WIDTH ) ) { return new LayoutTreeNode . ChildSizes ( 0 , 0 ) ; } if ( width == ( INFINITE ) ) { if ( preferredWidth == ( INFINITE ) ) { return new LayoutTreeNode . ChildSizes ( children [ 0 ] . computeMaximumSize ( vertical , height ) , children [ 1 ] . computeMaximumSize ( vertical , height ) ) ; } if ( preferredWidth == 0 ) { return new LayoutTreeNode . ChildSizes ( children [ 0 ] . computeMinimumSize ( vertical , height ) , children [ 1 ] . computeMinimumSize ( vertical , height ) ) ; } } int total = left + right ; double wLeft = left ; double wRight = right ; switch ( getCompressionBias ( ) ) { case - 1 : wLeft = 0.0 ; break ; case 1 : wRight = 0.0 ; break ; default : break ; } double wTotal = wLeft + wRight ; preferredWidth = Math . max ( 0 , subtract ( preferredWidth , LayoutTreeNode . SASH_WIDTH ) ) ; width = Math . max ( 0 , subtract ( width , LayoutTreeNode . SASH_WIDTH ) ) ; <START_BUG> int redistribute = preferredWidth - total ; <END_BUG> int leftMinimum = 0 ; if ( children [ 0 ] . hasSizeFlag ( vertical , MIN ) ) { leftMinimum = children [ 0 ] . computeMinimumSize ( vertical , height ) ; } int rightMinimum = 0 ; if ( children [ 1 ] . hasSizeFlag ( vertical , MIN ) ) { rightMinimum = children [ 1 ] . computeMinimumSize ( vertical , height ) ; } int leftMaximum = Math . max ( 0 , subtract ( width , rightMinimum ) ) ; int rightMaximum = Math . max ( 0 , subtract ( width , leftMinimum ) ) ; if ( children [ 0 ] . hasSizeFlag ( vertical , MAX ) ) { leftMaximum = Math . min ( leftMaximum , children [ 0 ] . computeMaximumSize ( vertical , height ) ) ; } if ( children [ 1 ] . hasSizeFlag ( vertical , MAX ) ) { rightMaximum = Math . min ( rightMaximum , children [ 1 ] . computeMaximumSize ( vertical , height ) ) ; } int idealLeft = Math . max ( leftMinimum , Math . min ( preferredWidth , ( left + ( ( int ) ( Math . round ( ( ( redistribute * wLeft ) // wTotal ) ) ) ) ) ) ) ; idealLeft = Math . max ( idealLeft , ( preferredWidth - rightMaximum ) ) ; idealLeft = Math . min ( idealLeft , leftMaximum ) ; if ( children [ 0 ] . hasSizeFlag ( vertical , FILL ) ) { idealLeft = children [ 0 ] . computePreferredSize ( vertical , leftMaximum , height , idealLeft ) ; } idealLeft = Math . max ( idealLeft , leftMinimum ) ; int idealRight = Math . max ( rightMinimum , ( preferredWidth - idealLeft ) ) ; rightMaximum = Math . max ( 0 , Math . min ( rightMaximum , subtract ( width , idealLeft ) ) ) ; idealRight = Math . min ( idealRight , rightMaximum ) ; if ( children [ 1 ] . hasSizeFlag ( vertical , FILL ) ) { idealRight = children [ 1 ] . computePreferredSize ( vertical , rightMaximum , height , idealRight ) ; } idealRight = Math . max ( idealRight , rightMinimum ) ; return new LayoutTreeNode . ChildSizes ( idealLeft , idealRight ) ; } protected int doGetSizeFlags ( boolean width ) { } public void doSetBounds ( Rectangle bounds ) { } public boolean isCompressible ( ) { } public int getCompressionBias ( ) { } boolean isLeftChild ( LayoutTree toTest ) { } LayoutTree getChild ( boolean left ) { } void setChild ( boolean left , LayoutPart part ) { }

Fix:
int redistribute = subtract ( preferredWidth , total ) ;