I ran into an issue with specifying a html element's width in a JLabel and thought I would run it up the flag pole here and see if anyone had any advice.
When I specify the width of an element using a "px" unit value, the resulting size is actually ~133%, whereas if I don't use a unit, or use "pt", I get the exact size I specified.
In the below example, if you change the "width: 100px" to "width: 100pt", you will get the right size.
This answer https://stackoverflow.com/a/6257861/131795 seems to be related, and the 72 dpi adjustment seems to match with the mismatch that I'm seeing in in my example.
I might be raging against an ancient piece of code here, but why is an absolute px value being converted and a pt value being treated as absolute?
public class test {
public static void main(String args[]) {
JFrame frame = new JFrame();
JLabel label = new JLabel("<html><div style='width: 100px; background-color: red;'>test</div>");
frame.getContentPane().add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 200);
frame.setVisible(true);
}
}