private void layoutSufficientSpace(Container parent,Dimension realDim,Dimension startPosition,int stretch){
  int remainingStretch=stretch;
  int remainingExpandable=expandable;
  for (  Component c : parent.getComponents()) {
    if (c.isVisible()) {
      Dimension cPref=getPreferred(c);
      shrink(cPref,realDim);
      int xAlign=0;
      int yAlign=0;
      EnumSet<SLayout> flags=constraints.get(c);
      if (flags.contains(SLayout.EXPAND_PERPENDICULAR)) {
        d.setSecondary(cPref,d.getSecondary(realDim));
      }
 else {
        xAlign=getXAlignment(c,realDim);
        yAlign=getYAlignment(c,realDim);
      }
      if ((remainingStretch > 0) && flags.contains(SLayout.EXPAND_AXIAL)) {
        int add=Math.max(1,remainingStretch / remainingExpandable);
        addToPrimary(cPref,add);
        remainingStretch-=add;
        remainingExpandable--;
      }
      c.setBounds(startPosition.width + xAlign,startPosition.height + yAlign,cPref.width,cPref.height);
      shiftByPrimary(startPosition,cPref);
      addToPrimary(startPosition,padding);
    }
  }
}

private void layoutSufficientSpace ( Container parent , Dimension realDim , Dimension startPosition , int stretch ) { int remainingStretch = stretch ; int remainingExpandable = expandable ; for ( Component c : parent . getComponents ( ) ) { if ( c . isVisible ( ) ) { Dimension cPref = getPreferred ( c ) ; shrink ( cPref , realDim ) ; int xAlign = 0 ; int yAlign = 0 ; EnumSet < SLayout > flags = constraints . get ( c ) ; if ( flags . contains ( SLayout . EXPAND_PERPENDICULAR ) ) { d . setSecondary ( cPref , d . getSecondary ( realDim ) ) ; } else { xAlign = getXAlignment ( c , realDim ) ; yAlign = getYAlignment ( c , realDim ) ; } if ( ( remainingStretch > 0 ) && flags . contains ( SLayout . EXPAND_AXIAL ) ) { int add = Math . max ( 1 , remainingStretch / remainingExpandable ) ; addToPrimary ( cPref , add ) ; remainingStretch -= add ; remainingExpandable -- ; } c . setBounds ( startPosition . width + xAlign , startPosition . height + yAlign , cPref . width , cPref . height ) ; shiftByPrimary ( startPosition , cPref ) ; addToPrimary ( startPosition , padding ) ; } } }
lay out the components , when we have sufficient space to do so .
