JLabel jlabel = new JLabel(test_str); FontMetrics fm = jlabel.getFontMetrics(new java.awt.Font("Times New Roman",java.awt.Font.PLAIN, 12)); System.out.println("string width="+fm.stringWidth(test_str));
。
JLabel jlabel = new JLabel(test_str); FontMetrics fm = jlabel.getFontMetrics(new java.awt.Font("Times New Roman",java.awt.Font.PLAIN, 12)); System.out.println("string width="+fm.stringWidth(test_str));