深圳网站网页制作公司,上海环球金融中心电梯,做国外直播网站,在线做app换行的时候确认不了长度#xff1a; import java.awt.*;public class Test {public static void main(String[] args) {String str1 淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘;String str2 AAAAAAAAAAAAAAAAAAAAAAAAA…换行的时候确认不了长度 import java.awt.*;public class Test {public static void main(String[] args) {String str1 淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘;String str2 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;String str4 cccccccccccccccccccccccccccccccccccccccccccccccccccc;String str3 111111111111111111111111111111111111111111111111111111111111111;FontMetrics fontMetrics GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(1, 1, Transparency.TRANSLUCENT).getGraphics().getFontMetrics();int width1 fontMetrics.stringWidth(str1);int width2 fontMetrics.stringWidth(str2);int width3 fontMetrics.stringWidth(str3);int width4 fontMetrics.stringWidth(str4);System.out.println(宽度 str1: width1);System.out.println(宽度 str2: width2);System.out.println(宽度 str3: width3);System.out.println(宽度 str4: width4);}}运行结果 宽度 str1: 444 宽度 str2: 364 宽度 str3: 441 宽度 str4: 312 这些长度在pdf里面都是一样的但是这里运行的宽度确实不同的目前这个问题还解决不了。