question: public static String clipStringIfNecessary ( JComponent c , FontMetrics fm , String string , int availTextWidth ) { if ( ( string == null ) || ( string . equals ( "" ) ) ) { return "" ; } int textWidth = SwingUtilities2 . stringWidth ( c , fm , string ) ; if ( textWidth > availTextWidth ) { return SwingUtilities2 . clipString ( c , fm , string , availTextWidth ) ; } return string ; }
target:  Clips the passed in String to the space provided.