-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);
}

the frame shows:

but the same HTML is visualized differently shown in a browser:

Martin S
  • 814
  • 2
  • 11
  • 24
  • pt is for print, not the web: https://www.w3.org/Style/Examples/007/units.en.html – Rob Sep 15 '17 at 12:03

1 Answers1

1

In short: pixels and points are different units, which mean different things.

One pixel is smaller than 1/72th of an inch on your display (or at least on whatever your platform thinks your display is).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335