private int moveComponents(Container target,int x,int y,int width,int height,int rowStart,int rowEnd,boolean ltr,boolean useBaseline,int[] ascent,int[] descent){
switch (newAlign) {
case LEFT:
    x+=ltr ? 0 : width;
  break;
case CENTER:
x+=width / 2;
break;
case RIGHT:
x+=ltr ? width : 0;
break;
case LEADING:
break;
case TRAILING:
x+=width;
break;
}
int maxAscent=0;
int nonbaselineHeight=0;
int baselineOffset=0;
if (useBaseline) {
int maxDescent=0;
for (int i=rowStart; i < rowEnd; i++) {
Component m=target.getComponent(i);
if (m.visible) {
if (ascent[i] >= 0) {
maxAscent=Math.max(maxAscent,ascent[i]);
maxDescent=Math.max(maxDescent,descent[i]);
}
 else {
nonbaselineHeight=Math.max(m.getHeight(),nonbaselineHeight);
}
}
}
height=Math.max(maxAscent + maxDescent,nonbaselineHeight);
baselineOffset=(height - maxAscent - maxDescent) / 2;
}
for (int i=rowStart; i < rowEnd; i++) {
Component m=target.getComponent(i);
if (m.isVisible()) {
int cy;
if (useBaseline && ascent[i] >= 0) {
cy=y + baselineOffset + maxAscent - ascent[i];
}
 else {
cy=y + (height - m.height) / 2;
}
if (ltr) {
m.setLocation(x,cy);
}
 else {
m.setLocation(target.width - x - m.width,cy);
}
x+=m.width + hgap;
}
}
return height;
}

private int moveComponents ( Container target , int x , int y , int width , int height , int rowStart , int rowEnd , boolean ltr , boolean useBaseline , int [ ] ascent , int [ ] descent ) { switch ( newAlign ) { case LEFT : x += ltr ? 0 : width ; break ; case CENTER : x += width / 2 ; break ; case RIGHT : x += ltr ? width : 0 ; break ; case LEADING : break ; case TRAILING : x += width ; break ; } int maxAscent = 0 ; int nonbaselineHeight = 0 ; int baselineOffset = 0 ; if ( useBaseline ) { int maxDescent = 0 ; for ( int i = rowStart ; i < rowEnd ; i ++ ) { Component m = target . getComponent ( i ) ; if ( m . visible ) { if ( ascent [ i ] >= 0 ) { maxAscent = Math . max ( maxAscent , ascent [ i ] ) ; maxDescent = Math . max ( maxDescent , descent [ i ] ) ; } else { nonbaselineHeight = Math . max ( m . getHeight ( ) , nonbaselineHeight ) ; } } } height = Math . max ( maxAscent + maxDescent , nonbaselineHeight ) ; baselineOffset = ( height - maxAscent - maxDescent ) / 2 ; } for ( int i = rowStart ; i < rowEnd ; i ++ ) { Component m = target . getComponent ( i ) ; if ( m . isVisible ( ) ) { int cy ; if ( useBaseline && ascent [ i ] >= 0 ) { cy = y + baselineOffset + maxAscent - ascent [ i ] ; } else { cy = y + ( height - m . height ) / 2 ; } if ( ltr ) { m . setLocation ( x , cy ) ; } else { m . setLocation ( target . width - x - m . width , cy ) ; } x += m . width + hgap ; } } return height ; }
centers the elements in the specified row , if there is any slack .
