Handling long string not visible in one entry of list field in Blackberry (show ...@ end)
This code returns string which can be shown in a field having width=width, 5 pixel margin on left and 5 pixel on right. private String getTextShown( String completeString, int width ) { if ( completeString == null ) return null; width = width - 10; Font font = listfield.getFont( ); if ( font.getAdvance( completeString ) < width ) return completeString; for ( int i = completeString.length( ) - 1; i > 0; i-- ) { completeString = completeString.substring( 0, i ); StringBuffer tempBuffer = new StringBuffer( completeString ); tempBuffer.append( "..." ); String temp = tempBuffer.toString( ); if ( font.getAdvance( temp ) < width ) { return temp; } } return completeString; } This can be called from protected void paint( Graphics graphics ) { String stringToDraw = getTextShown( ...