Spacing issues when print monospaced font - Existi

2019-08-02 00:00发布

问题:

I know there are a few other posts regarding this, but none of the solutions seem to have worked for me.

I have an issue in Java 1.6 with printing monospaced font. The spaces between words get messed up. This is an existing Java bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6784397

I am trying to print a bunch of JLabels which all contain monospaced font text. I tried to apply the workaround described in the bug ticket (i.e using FontDesignNetrics). However, the workaround only seems to work when I changed the JLabels to JTextFields (or other Text components). It does not work with JLabels for some reason. But...changing from JLabel to JTextField is not an option for me though, because it will have undesirable effects in other areas of the software.

Did anyone ever encounter this? Are there any other workarounds/solutions?