Java tutorial
//package com.java2s; public class Main { /** * Returns a multi-line tooltip by wrapping * the String input in <html> and inserting breaks <br>. * @param len the maximum line-length. The method will insert * a break at the space closest to this number. * @param input the input String. * @return the new multi-lined string. */ public static String multiLineToolTip(int len, String input) { String s = ""; int length = len; if (input == null) return ""; if (input.length() < length) return input; int i = 0; int lastSpace = 0; while (i + length < input.length()) { String temp = input.substring(i, i + length); lastSpace = temp.lastIndexOf(" "); s += temp.substring(0, lastSpace) + "<br>"; i += lastSpace + 1; } s += input.substring(i, input.length()); s = "<html>" + s + "</html>"; return s; } }