-2
public static void main(String[] args) {
JFrame frame = new JFrame("Test");
JTextPane pane = new JTextPane();
pane.setContentType("text/html");
pane.setText("<html>"
+ "<head>"
+ "<title> New Document </title>"
+ "</head>"
+ "<body>"
+ "<div style=\"font-size:20pt\">bbbbbbbb-20pt</div>"
+ "<div style=\"font-size:20px\">bbbbbbbb-20px</div>"
+ "</body>"
+ "</html>");
frame.add(pane, BorderLayout.CENTER);
frame.setSize(500, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
幀示出了:爲什麼在使用相同數字時,pt字體比JTextPane中的px字體小?
但相同的HTML是在瀏覽器中可視化不同所示:
pt用於打印,而不是網頁:https://www.w3.org/Style/Examples/007/units.en.html – Rob