public static boolean canDisplay(Font f,String s){
  int upTo=f.canDisplayUpTo(s);
  if (upTo >= s.length() || upTo == -1)   return true;
 else   return false;
}

public static boolean canDisplay ( Font f , String s ) { int upTo = f . canDisplayUpTo ( s ) ; if ( upTo >= s . length ( ) || upTo == - 1 ) return true ; else return false ; }
determines if a font can display up to a point in the string . returns - 1 if it can display the whole string .
