question: private static String layoutMenuItem ( JComponent c , FontMetrics fm , String text , FontMetrics fmAccel , String acceleratorText , Icon icon , Icon checkIcon , Icon arrowIcon , int verticalAlignment , int horizontalAlignment , int verticalTextPosition , int horizontalTextPosition , Rectangle viewR , Rectangle iconR , Rectangle textR , Rectangle acceleratorR , Rectangle checkIconR , Rectangle arrowIconR , int textIconGap , int menuItemGap ) { SwingUtilities . layoutCompoundLabel ( c , fm , text , icon , verticalAlignment , horizontalAlignment , verticalTextPosition , horizontalTextPosition , viewR , iconR , textR , textIconGap ) ; if ( ( acceleratorText == null ) || acceleratorText . equals ( "" ) ) { acceleratorR . width = acceleratorR . height = 0 ; acceleratorText = "" ; } else { acceleratorR . width = SwingUtilities2 . stringWidth ( c , fmAccel , acceleratorText ) ; acceleratorR . height = fmAccel . getHeight ( ) ; } if ( checkIcon != null ) { checkIconR . width = checkIcon . getIconWidth ( ) ; checkIconR . height = checkIcon . getIconHeight ( ) ; } else { checkIconR . width = checkIconR . height = 0 ; } if ( arrowIcon != null ) { arrowIconR . width = arrowIcon . getIconWidth ( ) ; arrowIconR . height = arrowIcon . getIconHeight ( ) ; } else { arrowIconR . width = arrowIconR . height = 0 ; } Rectangle labelR = iconR . union ( textR ) ; if ( MotifGraphicsUtils . isLeftToRight ( c ) ) { textR . x += checkIconR . width + menuItemGap ; iconR . x += checkIconR . width + menuItemGap ; acceleratorR . x = viewR . x + viewR . width - arrowIconR . width - menuItemGap - acceleratorR . width ; checkIconR . x = viewR . x ; arrowIconR . x = viewR . x + viewR . width - menuItemGap - arrowIconR . width ; } else { textR . x -= ( checkIconR . width + menuItemGap ) ; iconR . x -= ( checkIconR . width + menuItemGap ) ; acceleratorR . x = viewR . x + arrowIconR . width + menuItemGap ; checkIconR . x = viewR . x + viewR . width - checkIconR . width ; arrowIconR . x = viewR . x + menuItemGap ; } acceleratorR . y = labelR . y + ( labelR . height / 2 ) - ( acceleratorR . height / 2 ) ; arrowIconR . y = labelR . y + ( labelR . height / 2 ) - ( arrowIconR . height / 2 ) ; checkIconR . y = labelR . y + ( labelR . height / 2 ) - ( checkIconR . height / 2 ) ; return text ; }
target:  Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string.  Locations are computed relative to the viewR rectangle.