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;
}

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 ; }
clips the passed in string to the space provided .
